home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / sys / share / lev_yacc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  68.4 KB  |  2,234 lines  |  [TEXT/R*ch]

  1. #ifndef lint
  2. static char yysccsid[] = "@(#)yaccpar    1.9 (Berkeley) 02/21/93";
  3. #endif
  4. #define YYBYACC 1
  5. #define YYMAJOR 1
  6. #define YYMINOR 9
  7. #define yyclearin (yychar=(-1))
  8. #define yyerrok (yyerrflag=0)
  9. #define YYRECOVERING (yyerrflag!=0)
  10. #define YYPREFIX "yy"
  11. /*    SCCS Id: @(#)lev_comp.c    3.1    93/05/15    */
  12. /*    Copyright (c) 1989 by Jean-Christophe Collet */
  13. /* NetHack may be freely redistributed.  See license for details. */
  14.  
  15. /*
  16.  * This file contains the Level Compiler code
  17.  * It may handle special mazes & special room-levels
  18.  */
  19.  
  20. /* In case we're using bison in AIX.  This definition must be
  21.  * placed before any other C-language construct in the file
  22.  * excluding comments and preprocessor directives (thanks IBM
  23.  * for this wonderful feature...).
  24.  *
  25.  * Note: some cpps barf on this 'undefined control' (#pragma).
  26.  * Addition of the leading space seems to prevent barfage for now,
  27.  * and AIX will still see the directive in its non-standard locale.
  28.  */
  29.  
  30. #ifdef _AIX
  31.  #pragma alloca        /* keep leading space! */
  32. #endif
  33.  
  34. #include "hack.h"
  35. #include "sp_lev.h"
  36. #ifndef O_WRONLY
  37. # include <fcntl.h>
  38. #endif
  39. #ifndef O_CREAT    /* some older BSD systems do not define O_CREAT in <fcntl.h> */
  40. # include <sys/file.h>
  41. #endif
  42. #ifndef O_BINARY    /* used for micros, no-op for others */
  43. # define O_BINARY 0
  44. #endif
  45.  
  46. #ifdef MICRO
  47. # define OMASK FCMASK
  48. #else
  49. # define OMASK 0644
  50. #endif
  51.  
  52. #define MAX_REGISTERS    10
  53. #define ERR        (-1)
  54.  
  55. #define New(type)        (type *) alloc(sizeof(type))
  56. #define NewTab(type, size)    (type **) alloc(sizeof(type *) * size)
  57.  
  58. #ifdef MICRO
  59. # undef exit
  60. extern void FDECL(exit, (int));
  61. #endif
  62.  
  63. extern void FDECL(yyerror, (const char *));
  64. extern void FDECL(yywarning, (const char *));
  65. extern int NDECL(yylex);
  66. int NDECL(yyparse);
  67.  
  68. extern char *FDECL(dup_string,(char *));
  69. extern int FDECL(get_floor_type, (CHAR_P));
  70. extern int FDECL(get_room_type, (char *));
  71. extern int FDECL(get_trap_type, (char *));
  72. extern int FDECL(get_monster_id, (char *, CHAR_P));
  73. extern int FDECL(get_object_id, (char *));
  74. extern boolean FDECL(check_monster_char, (CHAR_P));
  75. extern boolean FDECL(check_object_char, (CHAR_P));
  76. extern char FDECL(what_map_char, (CHAR_P));
  77. extern void FDECL(scan_map, (char *));
  78. extern void NDECL(wallify_map);
  79. extern boolean NDECL(check_subrooms);
  80. extern void FDECL(check_coord, (int, int, const char *));
  81. extern void NDECL(store_part);
  82. extern void NDECL(store_room);
  83. extern void FDECL(write_maze, (int, specialmaze *));
  84. extern void FDECL(write_lev, (int, splev *));
  85. extern void FDECL(free_rooms, (room **, int));
  86.  
  87. static struct reg {
  88.     int x1, y1;
  89.     int x2, y2;
  90. }        current_region;
  91.  
  92. static struct coord {
  93.     int x;
  94.     int y;
  95. }        current_coord, current_align;
  96.  
  97. static struct size {
  98.     int height;
  99.     int width;
  100. }        current_size;
  101.  
  102. char tmpmessage[256];
  103. altar *tmpaltar[256];
  104. lad *tmplad[256];
  105. stair *tmpstair[256];
  106. digpos *tmpdig[256];
  107. digpos *tmppass[32];
  108. char *tmpmap[ROWNO];
  109. region *tmpreg[256];
  110. lev_region *tmplreg[32];
  111. door *tmpdoor[256];
  112. room_door *tmprdoor[256];
  113. trap *tmptrap[256];
  114. monster *tmpmonst[256];
  115. object *tmpobj[256];
  116. drawbridge *tmpdb[256];
  117. walk *tmpwalk[256];
  118. gold *tmpgold[256];
  119. fountain *tmpfountain[256];
  120. sink *tmpsink[256];
  121. pool *tmppool[256];
  122. engraving *tmpengraving[256];
  123. mazepart *tmppart[10];
  124. room *tmproom[MAXNROFROOMS*2];
  125. corridor *tmpcor[256];
  126.  
  127. static specialmaze maze;
  128. static splev special_lev;
  129. static lev_init init_lev;
  130.  
  131. static char olist[MAX_REGISTERS], mlist[MAX_REGISTERS];
  132. static struct coord plist[MAX_REGISTERS];
  133.  
  134. int n_olist = 0, n_mlist = 0, n_plist = 0;
  135.  
  136. unsigned int nlreg = 0, nreg = 0, ndoor = 0, ntrap = 0, nmons = 0, nobj = 0;
  137. unsigned int ndb = 0, nwalk = 0, npart = 0, ndig = 0, nlad = 0, nstair = 0;
  138. unsigned int naltar = 0, ncorridor = 0, nrooms = 0, ngold = 0, nengraving = 0;
  139. unsigned int nfountain = 0, npool = 0, nsink = 0, npass = 0;
  140.  
  141. static unsigned long lev_flags = 0;
  142.  
  143. unsigned int max_x_map, max_y_map;
  144.  
  145. static xchar in_room;
  146.  
  147. extern int fatal_error;
  148. extern int want_warnings;
  149. extern const char *fname;
  150.  
  151. typedef union
  152. {
  153.     int    i;
  154.     char*    map;
  155.     struct {
  156.         xchar room;
  157.         xchar wall;
  158.         xchar door;
  159.     } corpos;
  160. } YYSTYPE;
  161. #define CHAR 257
  162. #define INTEGER 258
  163. #define BOOLEAN 259
  164. #define MESSAGE_ID 260
  165. #define MAZE_ID 261
  166. #define LEVEL_ID 262
  167. #define LEV_INIT_ID 263
  168. #define GEOMETRY_ID 264
  169. #define NOMAP_ID 265
  170. #define OBJECT_ID 266
  171. #define MONSTER_ID 267
  172. #define TRAP_ID 268
  173. #define DOOR_ID 269
  174. #define DRAWBRIDGE_ID 270
  175. #define MAZEWALK_ID 271
  176. #define WALLIFY_ID 272
  177. #define REGION_ID 273
  178. #define FILLING 274
  179. #define RANDOM_OBJECTS_ID 275
  180. #define RANDOM_MONSTERS_ID 276
  181. #define RANDOM_PLACES_ID 277
  182. #define ALTAR_ID 278
  183. #define LADDER_ID 279
  184. #define STAIR_ID 280
  185. #define NON_DIGGABLE_ID 281
  186. #define NON_PASSWALL_ID 282
  187. #define ROOM_ID 283
  188. #define PORTAL_ID 284
  189. #define TELEPRT_ID 285
  190. #define BRANCH_ID 286
  191. #define LEV 287
  192. #define CHANCE_ID 288
  193. #define CORRIDOR_ID 289
  194. #define GOLD_ID 290
  195. #define ENGRAVING_ID 291
  196. #define FOUNTAIN_ID 292
  197. #define POOL_ID 293
  198. #define SINK_ID 294
  199. #define NONE 295
  200. #define RAND_CORRIDOR_ID 296
  201. #define DOOR_STATE 297
  202. #define LIGHT_STATE 298
  203. #define CURSE_TYPE 299
  204. #define ENGRAVING_TYPE 300
  205. #define DIRECTION 301
  206. #define RANDOM_TYPE 302
  207. #define O_REGISTER 303
  208. #define M_REGISTER 304
  209. #define P_REGISTER 305
  210. #define A_REGISTER 306
  211. #define ALIGNMENT 307
  212. #define LEFT_OR_RIGHT 308
  213. #define CENTER 309
  214. #define TOP_OR_BOT 310
  215. #define ALTAR_TYPE 311
  216. #define UP_OR_DOWN 312
  217. #define SUBROOM_ID 313
  218. #define NAME_ID 314
  219. #define FLAGS_ID 315
  220. #define FLAG_TYPE 316
  221. #define MON_ATTITUDE 317
  222. #define MON_ALERTNESS 318
  223. #define MON_APPEARANCE 319
  224. #define STRING 320
  225. #define MAP_ID 321
  226. #define YYERRCODE 256
  227. short yylhs[] = {                                        -1,
  228.     0,    0,   38,   38,   39,   39,   40,   41,   33,   24,
  229.    24,   14,   14,   20,   20,   21,   21,   42,   42,   47,
  230.    44,   44,   48,   48,   45,   45,   51,   51,   46,   46,
  231.    53,   54,   54,   55,   55,   37,   52,   52,   58,   56,
  232.    10,   10,   61,   61,   59,   59,   62,   62,   60,   60,
  233.    57,   57,   63,   63,   63,   63,   63,   63,   63,   63,
  234.    63,   63,   63,   63,   63,   64,   65,   66,   15,   15,
  235.    13,   13,   12,   12,   32,   11,   11,   43,   43,   77,
  236.    78,   78,   81,    1,    1,    2,    2,   79,   79,   82,
  237.    82,   82,   49,   49,   50,   50,   83,   85,   83,   80,
  238.    80,   86,   86,   86,   86,   86,   86,   86,   86,   86,
  239.    86,   86,   86,   86,   86,   86,   86,   86,   86,   86,
  240.    86,  101,   67,  100,  100,  102,  102,  102,  102,  102,
  241.   104,   68,  103,  103,  103,   16,   16,   17,   17,   87,
  242.    69,   88,   94,   95,   96,   76,  105,   90,  106,   91,
  243.   107,  109,   92,  110,   93,  108,  108,   23,   23,   71,
  244.    72,   73,   97,   98,   89,   70,   74,   75,   26,   26,
  245.    26,   29,   29,   29,   34,   34,   35,   35,    3,    3,
  246.     4,    4,   22,   22,   22,   99,   99,   99,    5,    5,
  247.     6,    6,    7,    7,    7,    8,    8,  113,   30,   27,
  248.     9,   84,   25,   28,   31,   36,   36,   18,   18,   19,
  249.    19,  112,  111,
  250. };
  251. short yylen[] = {                                         2,
  252.     0,    1,    1,    2,    1,    1,    5,    7,    3,    0,
  253.    13,    1,    1,    0,    3,    3,    1,    0,    2,    3,
  254.     0,    2,    3,    3,    0,    1,    1,    2,    1,    1,
  255.     1,    0,    2,    5,    5,    7,    2,    2,   12,   12,
  256.     0,    2,    5,    1,    5,    1,    5,    1,    5,    1,
  257.     0,    2,    1,    1,    1,    1,    1,    1,    1,    1,
  258.     1,    1,    1,    1,    1,    3,    3,    9,    1,    1,
  259.     1,    1,    1,    1,    5,    1,    1,    1,    2,    3,
  260.     1,    2,    5,    1,    1,    1,    1,    0,    2,    3,
  261.     3,    3,    1,    3,    1,    3,    1,    0,    4,    0,
  262.     2,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  263.     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  264.     1,    0,    9,    0,    2,    2,    2,    2,    2,    3,
  265.     0,    9,    0,    4,    6,    1,    1,    1,    1,    5,
  266.     5,    7,    5,    1,    5,    5,    0,    8,    0,    8,
  267.     0,    0,    8,    0,    6,    0,    2,    1,   10,    3,
  268.     3,    3,    3,    3,    8,    7,    5,    7,    1,    1,
  269.     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  270.     1,    1,    0,    2,    4,    1,    1,    1,    1,    1,
  271.     1,    1,    1,    1,    1,    1,    1,    4,    4,    4,
  272.     4,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  273.     1,    5,    9,
  274. };
  275. short yydefred[] = {                                      0,
  276.     0,    0,    0,    0,    0,    2,    0,    5,    6,    0,
  277.     0,    0,    0,    0,    4,  205,    0,    9,    0,    0,
  278.     0,    0,    0,    0,   15,    0,    0,    0,    0,   21,
  279.    76,   77,   75,    0,    0,    0,    0,   81,    7,    0,
  280.    88,    0,   19,    0,   16,    0,   20,    0,   79,    0,
  281.    82,    0,    0,    0,    0,    0,   22,   26,    0,   51,
  282.    51,    0,   84,   85,    0,    0,    0,    0,    0,   89,
  283.     0,    0,    0,    0,   31,    8,   29,    0,   28,    0,
  284.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  285.     0,    0,  144,    0,    0,    0,    0,    0,    0,    0,
  286.     0,    0,    0,    0,    0,  102,  103,  105,  112,  113,
  287.   118,  119,  117,  101,  104,  106,  107,  108,  109,  110,
  288.   111,  114,  115,  116,  120,  121,  204,    0,   23,  203,
  289.     0,   24,  182,    0,  181,    0,    0,   33,    0,    0,
  290.     0,    0,    0,    0,   52,   53,   54,   55,   56,   57,
  291.    58,   59,   60,   61,   62,   63,   64,   65,    0,   87,
  292.    86,   83,   90,   92,    0,   91,    0,  202,    0,    0,
  293.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  294.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  295.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  296.   173,    0,  172,    0,  174,  170,    0,  169,    0,  171,
  297.   180,    0,  179,  189,  190,    0,  188,    0,    0,  186,
  298.   187,    0,    0,    0,    0,    0,    0,    0,  147,    0,
  299.   158,  163,  164,  149,  151,  154,  208,  209,    0,    0,
  300.   160,   94,   96,  191,  192,    0,    0,    0,    0,   69,
  301.    70,    0,   67,  162,  161,   66,    0,    0,    0,    0,
  302.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  303.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  304.     0,    0,    0,    0,    0,    0,    0,    0,   99,    0,
  305.   178,  177,    0,    0,  176,  175,    0,  141,  140,    0,
  306.     0,  143,    0,    0,  195,    0,  193,    0,  194,  145,
  307.     0,    0,    0,  146,    0,    0,    0,  167,  210,  211,
  308.     0,   44,    0,    0,   46,    0,    0,    0,   35,   34,
  309.     0,    0,  212,  199,    0,  200,    0,  198,    0,    0,
  310.     0,    0,    0,    0,    0,    0,    0,  152,  155,    0,
  311.     0,    0,    0,    0,    0,    0,    0,  131,  122,  142,
  312.     0,    0,    0,  197,  196,  166,    0,    0,    0,    0,
  313.   168,    0,   48,    0,    0,    0,   50,    0,    0,    0,
  314.    71,   72,    0,   12,   13,   11,    0,  124,    0,    0,
  315.   165,  201,    0,  148,  150,    0,  153,    0,    0,    0,
  316.     0,    0,    0,   73,   74,    0,    0,    0,  132,    0,
  317.     0,    0,    0,  157,   43,    0,    0,   45,    0,    0,
  318.    36,   68,  137,  136,    0,    0,    0,  125,    0,    0,
  319.     0,    0,    0,   40,    0,   39,    0,    0,  127,  128,
  320.     0,  129,  126,  213,  185,    0,   47,   42,   49,  138,
  321.   139,  134,    0,  130,  159,    0,  207,  206,  135,
  322. };
  323. short yydgoto[] = {                                       3,
  324.    65,  162,  212,  134,  216,  246,  308,  366,  309,  434,
  325.    33,  406,  383,  386,  252,  426,  452,  239,  321,   13,
  326.    25,  391,  229,   21,  131,  209,  210,  128,  204,  205,
  327.   135,    4,    5,  297,  293,  459,  249,    6,    7,    8,
  328.     9,   28,   39,   44,   56,   76,   29,   57,  129,  132,
  329.    58,   59,   77,   78,  138,   60,   80,   61,  327,  379,
  330.   324,  375,  145,  146,  147,  148,  149,  150,  151,  152,
  331.   153,  154,  155,  156,  157,  158,   40,   41,   50,   69,
  332.    42,   70,  166,  167,  200,  114,  115,  116,  117,  118,
  333.   119,  120,  121,  122,  123,  124,  125,  126,  230,  410,
  334.   388,  428,  409,  387,  275,  277,  278,  397,  370,  279,
  335.   231,  220,  221,
  336. };
  337. short yysindex[] = {                                   -122,
  338.   -26,    4,    0, -231, -231,    0, -122,    0,    0, -267,
  339.  -267,   37, -156, -156,    0,    0,   70,    0, -199,   72,
  340.  -103, -103, -226,  107,    0,  -99,  101, -123, -103,    0,
  341.     0,    0,    0, -199,  116, -158,  105,    0,    0, -123,
  342.     0, -157,    0, -234,    0,  -92,    0, -164,    0, -139,
  343.     0,  108,  109,  110,  111, -126,    0,    0, -262,    0,
  344.     0,  127,    0,    0,  128,  118,  119,  120,  -78,    0,
  345.   -83,  -74, -272, -272,    0,    0,    0, -108,    0, -223,
  346.  -223,  -79, -161,  -83,  -74,  144,  138,  139,  140,  141,
  347.   147,  151,    0,  152,  153,  157,  158,  159,  160,  161,
  348.   162,  165,  166,  167,  168,    0,    0,    0,    0,    0,
  349.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  350.     0,    0,    0,    0,    0,    0,    0,  142,    0,    0,
  351.   183,    0,    0,  184,    0,  185,  173,    0,  174,  175,
  352.   176,  177,  178,  179,    0,    0,    0,    0,    0,    0,
  353.     0,    0,    0,    0,    0,    0,    0,    0,  194,    0,
  354.     0,    0,    0,    0,  -73,    0,    0,    0, -229, -241,
  355.  -242, -201,   79,   79,  199,   79,   79,   95,  199,  199,
  356.   -35,  -35,  -35, -222,   79,   79,  -83,  -74, -276, -276,
  357.   201, -230,   79,  -16,   79,   79, -267,  -15,  202,  203,
  358.     0,  154,    0,  204,    0,    0,  163,    0,  205,    0,
  359.     0,  211,    0,    0,    0,  212,    0,  169,  213,    0,
  360.     0,  214,    1,  217,  218,  258,  294,   84,    0,  303,
  361.     0,    0,    0,    0,    0,    0,    0,    0,  305,  312,
  362.     0,    0,    0,    0,    0,  314,  319,  125,  343,    0,
  363.     0,  344,    0,    0,    0,    0,  348,  136,  144,  137,
  364.  -216,  145, -209,   79,   79,  148,  -58,   98,  357, -276,
  365.  -248,  124,  180,  393,  396,  129,  398,  401,  426,   79,
  366.  -177,  -37,  -13,  431,  -36, -201, -276,  435,    0,  384,
  367.     0,    0,  436,  394,    0,    0,  444,    0,    0,  405,
  368.   445,    0,  236,  455,    0,  388,    0,  463,    0,    0,
  369.   464,  251,  -35,    0,  -35,  -35,  -35,    0,    0,    0,
  370.   470,    0,  260,  476,    0,  263,  478,  223,    0,    0,
  371.   481,  483,    0,    0,   79,    0,   79,    0, -201,  484,
  372.  -272,  272, -255,  273,   65,  488,  491,    0,    0, -267,
  373.   498,   -5,  500,   24,  501, -155, -219,    0,    0,    0,
  374.   289,  504,  456,    0,    0,    0,  506,  242, -267,  511,
  375.     0,  298,    0, -164,  513,  300,    0,  304,  520, -221,
  376.     0,    0,  522,    0,    0,    0,  523,    0,  524,  295,
  377.     0,    0,  313,    0,    0,  261,    0,  529,  532,   24,
  378.   536,  534, -267,    0,    0,  538, -221, -212,    0,  537,
  379.   322,  539,  540,    0,    0, -161,  541,    0,  328,  541,
  380.     0,    0,    0,    0,  543,  546, -186,    0,  550,  333,
  381.   335,  553,  337,    0,  556,    0, -220, -220,    0,    0,
  382.  -267,    0,    0,    0,    0,  557,    0,    0,    0,    0,
  383.     0,    0,  555,    0,    0, -270,    0,    0,    0,
  384. };
  385. short yyrindex[] = {                                    600,
  386.     0,    0,    0, -166,  230,    0,  601,    0,    0,    0,
  387.     0,    0, -138,  240,    0,    0,    0,    0,    0,    0,
  388.  -109,  299,    0,  221,    0,    0,    0,    0,  276,    0,
  389.     0,    0,    0,    0,    0,    0,    0,    0,    0,   17,
  390.     0,    0,    0,   52,    0,    0,    0,    0,    0,  386,
  391.     0,    0,    0,    0,    0,   75,    0,    0,  100,    0,
  392.     0,    0,    0,    0,    0,    0,    0,    0,  115,    0,
  393.     0,    0,    0,    0,    0,    0,    0,  113,    0,   89,
  394.   250,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  395.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  396.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  397.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  398.     0,    0,    0,    0,    0,    0,    0,  143,    0,    0,
  399.   182,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  400.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  401.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  402.     0,    0,    0,    0,    0,    0,  354,    0,    0,    0,
  403.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  404.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  405.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  406.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  407.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  408.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  409.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  410.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  411.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  412.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  413.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  414.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  415.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  416.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  417.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  418.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  419.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  420.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  421.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  422.     0,  430,    0,    0,    0,    0,    0,    0,    0,  469,
  423.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  424.     0,    0,    0,    0,    0,    0,    2,    0,    0,    0,
  425.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  426.     0,    0,    0,    0,    0,    0,    0,    0,    0,   39,
  427.     0,  503,    0,    0,    0,    0,   77,    0,    0,   77,
  428.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  429.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  430.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  431.     0,    0,    0,    0,    0,    0,    0,    0,    0,
  432. };
  433. short yygindex[] = {                                      0,
  434.   228,  187,    0,  -64, -273, -182,  181,    0,    0,  186,
  435.     0,  197,    0,    0,    0,    0,  171,    0,    0,  602,
  436.   571,    0, -163,  596,  441,    0,    0,  448,    0,    0,
  437.   -10,    0,    0,    0,    0,    0,  329,  606,    0,    0,
  438.     0,   63,  588,    0,    0,    0,    0,    0,  -77,  -76,
  439.   578,    0,    0,    0,    0,    0,  580,    0,    0,  243,
  440.     0,    0,    0,    0,    0,    0,  573,  591,  592,  593,
  441.   594,    0,    0,  604,  605,  610,    0,    0,    0,    0,
  442.     0,    0,  390,    0,    0,    0,    0,    0,    0,    0,
  443.     0,    0,    0,    0,    0,    0,    0,    0, -162,    0,
  444.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  445.   -51,  -80,    0,
  446. };
  447. #define YYTABLESIZE 795
  448. short yytable[] = {                                      17,
  449.    18,  133,  323,  248,  223,  168,  163,  247,  164,  136,
  450.   219,  222,  331,  225,  226,  130,   78,  234,  235,  236,
  451.    54,  244,  240,  241,  457,  245,  326,  127,  250,  133,
  452.    31,   10,  254,  255,  374,  237,  404,  450,  123,  384,
  453.    52,   53,   87,   88,   89,  139,  364,   16,   54,  458,
  454.    55,   25,   16,  305,   95,  365,  140,  306,  307,  211,
  455.   206,   11,  207,  378,  141,  360,  103,  104,  105,  142,
  456.   143,  251,  201,  202,   32,   32,   41,   16,   55,  238,
  457.   405,  451,  385,   12,   30,  291,  423,  304,   37,  424,
  458.   144,   43,  295,   14,   19,  214,   14,   14,   14,   27,
  459.   215,  298,  299,   16,  332,  333,   20,  425,  361,  242,
  460.    16,  243,   30,   23,   80,  305,   24,  318,  165,  306,
  461.   307,   10,  319,  224,  320,   10,   10,  232,  233,   26,
  462.   439,  440,  441,   16,  228,   66,   67,   68,    1,    2,
  463.    37,   38,   93,   63,   64,  381,  382,  160,  161,  346,
  464.    34,  347,  348,  349,   18,   18,   27,   35,   36,   46,
  465.   213,   47,   48,   51,   62,   71,   72,   73,   74,   75,
  466.    82,   83,  358,  127,  359,   84,   85,   86,  168,  159,
  467.   137,   95,  130,  165,  199,  187,  256,   87,   88,   89,
  468.    90,   91,   92,   93,   94,  169,  170,  171,  172,   95,
  469.    96,   97,   98,   99,  173,  100,  101,  102,  174,  175,
  470.   176,  103,  104,  105,  177,  178,  179,  180,  181,  182,
  471.    17,  329,  183,  184,  185,  186,  188,  189,  190,   14,
  472.   191,  192,  193,  194,  195,  196,  197,  198,  223,   10,
  473.   248,  253,  301,  257,  260,  258,  259,  261,  263,   38,
  474.   292,  227,  296,  262,  264,  265,  267,  268,  269,  266,
  475.   270,  271,  133,  133,  322,  133,  133,  133,  133,  133,
  476.   133,  133,  133,  133,  133,   18,  362,   78,   78,  133,
  477.   133,  133,  133,  133,  133,  133,  133,  133,  325,  133,
  478.   133,  133,  133,  133,  133,  133,  373,  133,   18,  123,
  479.   123,  272,  123,  123,  123,  123,  123,  123,  123,  123,
  480.   123,  123,   25,   25,  133,  133,  123,  123,  123,  123,
  481.   123,  123,  123,  123,  123,  377,  123,  123,  123,  123,
  482.   123,  123,  123,  273,  123,   32,   32,   41,   41,  371,
  483.    25,  274,   41,   41,   41,   41,  276,   25,  280,   37,
  484.    37,  123,  123,   97,   41,  281,   41,  282,  395,   41,
  485.    27,   27,  283,   32,   41,   41,   41,   41,   41,   41,
  486.    41,   37,   41,   30,   30,   80,   80,   37,   80,   80,
  487.   217,  227,  284,  218,   37,  100,  285,  286,   27,   41,
  488.    41,  287,  420,  288,  290,   27,  217,   98,  302,  218,
  489.   303,   37,  294,   93,   93,  300,   93,   93,   93,   93,
  490.    93,   93,   93,   93,   93,   93,  443,   93,   93,   93,
  491.    93,   93,   93,   93,   93,   93,   93,   93,   93,  183,
  492.   454,   93,   93,   93,   93,  310,  312,  311,   93,  313,
  493.   314,  315,   95,   95,  316,   95,   95,   95,   95,   95,
  494.    95,   95,   95,   95,   95,   93,   95,   95,   95,   95,
  495.    95,   95,   95,   95,   95,   95,   95,   95,  156,  317,
  496.    95,   95,   95,   95,  328,  333,  334,   95,  342,  335,
  497.    17,   17,   17,   17,   17,   17,  336,  337,  339,   14,
  498.    14,   14,   14,  340,   95,   17,   17,  338,  341,   10,
  499.    10,   10,  184,   17,   14,   14,  343,  344,  345,   17,
  500.    38,   38,   14,  350,   10,   10,   17,  351,   14,  352,
  501.   353,  354,   10,  355,  356,   14,  357,  361,   10,  363,
  502.   367,  368,   38,   17,  369,   10,   18,   18,   38,   18,
  503.    18,  372,   14,  376,  380,   38,  389,  390,  392,  393,
  504.    18,   18,   10,  394,  396,  398,  400,  401,   18,   18,
  505.    18,  402,   38,  403,   18,  407,  408,  411,  412,  415,
  506.   413,   18,  414,   18,   18,  416,  418,  419,  421,  429,
  507.   427,   18,  430,  431,  433,  435,  437,   18,   18,  438,
  508.   444,  445,  446,  447,   18,  448,  449,  455,  456,    1,
  509.     3,  399,  432,  422,   45,  436,   14,  442,  453,   22,
  510.   208,   18,   15,  330,   97,   97,  203,   97,   97,   97,
  511.    97,   97,   97,   97,   97,   97,   97,   49,   97,   97,
  512.    97,   97,   97,   97,   97,   97,   79,   97,   97,   97,
  513.    81,  106,  417,   97,   97,   97,  100,  100,  289,  100,
  514.   100,  100,  100,  100,  100,  100,  100,  100,  100,  107,
  515.   108,  109,  110,  100,  100,  100,  100,  100,    0,  100,
  516.   100,  100,  111,  112,    0,  100,  100,  100,  113,    0,
  517.     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  518.   183,  183,    0,  183,  183,  183,  183,  183,  183,  183,
  519.   183,  183,  183,    0,    0,    0,    0,  183,  183,  183,
  520.   183,  183,    0,  183,  183,  183,    0,    0,    0,  183,
  521.   183,  183,    0,    0,    0,    0,    0,    0,    0,  156,
  522.   156,    0,  156,  156,  156,  156,  156,  156,  156,  156,
  523.   156,  156,    0,    0,    0,    0,  156,  156,  156,  156,
  524.   156,    0,  156,  156,  156,    0,    0,    0,  156,  156,
  525.   156,    0,    0,  184,  184,    0,  184,  184,  184,  184,
  526.   184,  184,  184,  184,  184,  184,    0,    0,    0,    0,
  527.   184,  184,  184,  184,  184,    0,  184,  184,  184,    0,
  528.     0,    0,  184,  184,  184,
  529. };
  530. short yycheck[] = {                                      10,
  531.    11,    0,   40,   40,   40,   86,   84,  190,   85,   74,
  532.   173,  174,  286,  176,  177,  257,    0,  181,  182,  183,
  533.   283,  298,  185,  186,  295,  302,   40,  257,  259,  302,
  534.   257,   58,  195,  196,   40,  258,  258,  258,    0,  259,
  535.   275,  276,  266,  267,  268,  269,  302,  320,  283,  320,
  536.   313,    0,  320,  302,  278,  311,  280,  306,  307,  302,
  537.   302,   58,  304,   40,  288,  339,  290,  291,  292,  293,
  538.   294,  302,  302,  303,    0,  302,    0,  320,  313,  302,
  539.   302,  302,  302,  315,   22,  302,  299,  270,    0,  302,
  540.   314,   29,  302,  260,   58,  297,  263,  264,  265,    0,
  541.   302,  264,  265,  320,  287,   41,  263,  320,   44,  187,
  542.   320,  188,    0,   44,    0,  302,  316,  280,   40,  306,
  543.   307,  260,  300,  175,  302,  264,  265,  179,  180,   58,
  544.   317,  318,  319,  320,   40,  275,  276,  277,  261,  262,
  545.   264,  265,    0,  308,  309,  301,  302,  309,  310,  313,
  546.    44,  315,  316,  317,  264,  265,  260,  257,   58,   44,
  547.   171,  320,   58,  321,  257,   58,   58,   58,   58,  296,
  548.    44,   44,  335,  257,  337,   58,   58,   58,  259,  259,
  549.   289,    0,  257,   40,  258,   44,  197,  266,  267,  268,
  550.   269,  270,  271,  272,  273,   58,   58,   58,   58,  278,
  551.   279,  280,  281,  282,   58,  284,  285,  286,   58,   58,
  552.    58,  290,  291,  292,   58,   58,   58,   58,   58,   58,
  553.     0,  258,   58,   58,   58,   58,   44,   44,   44,    0,
  554.    58,   58,   58,   58,   58,   58,   58,   44,   40,    0,
  555.    40,  258,  301,  259,   91,   44,   44,   44,   44,    0,
  556.   261,  287,  263,   91,   44,   44,   44,   44,  258,   91,
  557.    44,   44,  261,  262,  302,  264,  265,  266,  267,  268,
  558.   269,  270,  271,  272,  273,    0,  341,  261,  262,  278,
  559.   279,  280,  281,  282,  283,  284,  285,  286,  302,  288,
  560.   289,  290,  291,  292,  293,  294,  302,  296,    0,  261,
  561.   262,   44,  264,  265,  266,  267,  268,  269,  270,  271,
  562.   272,  273,  261,  262,  313,  314,  278,  279,  280,  281,
  563.   282,  283,  284,  285,  286,  302,  288,  289,  290,  291,
  564.   292,  293,  294,   40,  296,  261,  262,  261,  262,  350,
  565.   289,  258,  266,  267,  268,  269,   44,  296,   44,  261,
  566.   262,  313,  314,    0,  278,   44,  280,   44,  369,  283,
  567.   261,  262,   44,  289,  288,  289,  290,  291,  292,  293,
  568.   294,  283,  296,  261,  262,  261,  262,  289,  264,  265,
  569.   302,  287,  258,  305,  296,    0,   44,   44,  289,  313,
  570.   314,   44,  403,  258,  258,  296,  302,   44,  301,  305,
  571.    44,  313,  258,  261,  262,  258,  264,  265,  266,  267,
  572.   268,  269,  270,  271,  272,  273,  427,  275,  276,  277,
  573.   278,  279,  280,  281,  282,  283,  284,  285,  286,    0,
  574.   441,  289,  290,  291,  292,  312,   44,  258,  296,   44,
  575.   312,   44,  261,  262,   44,  264,  265,  266,  267,  268,
  576.   269,  270,  271,  272,  273,  313,  275,  276,  277,  278,
  577.   279,  280,  281,  282,  283,  284,  285,  286,    0,   44,
  578.   289,  290,  291,  292,   44,   41,   93,  296,   91,   44,
  579.   260,  261,  262,  263,  264,  265,   93,   44,   44,  260,
  580.   261,  262,  263,  258,  313,  275,  276,   93,   44,  260,
  581.   261,  262,    0,  283,  275,  276,   44,   44,  258,  289,
  582.   261,  262,  283,   44,  275,  276,  296,  258,  289,   44,
  583.   258,   44,  283,  301,   44,  296,   44,   44,  289,  258,
  584.   258,   44,  283,  313,   44,  296,  261,  262,  289,  264,
  585.   265,   44,  313,   44,   44,  296,  258,   44,   93,   44,
  586.   275,  276,  313,  312,   44,  258,   44,  258,  283,  261,
  587.   262,  258,  313,   44,  289,   44,   44,   44,  274,   41,
  588.   258,  296,  312,  275,  276,   44,   41,   44,   41,  258,
  589.    44,  283,   44,   44,   44,  258,   44,  289,  313,   44,
  590.    41,  259,  258,   41,  296,  259,   41,   41,   44,    0,
  591.     0,  374,  416,  407,   34,  420,    5,  427,  438,   14,
  592.   170,  313,    7,  285,  261,  262,  169,  264,  265,  266,
  593.   267,  268,  269,  270,  271,  272,  273,   40,  275,  276,
  594.   277,  278,  279,  280,  281,  282,   59,  284,  285,  286,
  595.    61,   69,  400,  290,  291,  292,  261,  262,  259,  264,
  596.   265,  266,  267,  268,  269,  270,  271,  272,  273,   69,
  597.    69,   69,   69,  278,  279,  280,  281,  282,   -1,  284,
  598.   285,  286,   69,   69,   -1,  290,  291,  292,   69,   -1,
  599.    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
  600.   261,  262,   -1,  264,  265,  266,  267,  268,  269,  270,
  601.   271,  272,  273,   -1,   -1,   -1,   -1,  278,  279,  280,
  602.   281,  282,   -1,  284,  285,  286,   -1,   -1,   -1,  290,
  603.   291,  292,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  261,
  604.   262,   -1,  264,  265,  266,  267,  268,  269,  270,  271,
  605.   272,  273,   -1,   -1,   -1,   -1,  278,  279,  280,  281,
  606.   282,   -1,  284,  285,  286,   -1,   -1,   -1,  290,  291,
  607.   292,   -1,   -1,  261,  262,   -1,  264,  265,  266,  267,
  608.   268,  269,  270,  271,  272,  273,   -1,   -1,   -1,   -1,
  609.   278,  279,  280,  281,  282,   -1,  284,  285,  286,   -1,
  610.    -1,   -1,  290,  291,  292,
  611. };
  612. #define YYFINAL 3
  613. #ifndef YYDEBUG
  614. #define YYDEBUG 0
  615. #endif
  616. #define YYMAXTOKEN 321
  617. #if YYDEBUG
  618. char *yyname[] = {
  619. "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  620. 0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,0,0,0,
  621. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,
  622. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  623. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  624. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  625. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR",
  626. "INTEGER","BOOLEAN","MESSAGE_ID","MAZE_ID","LEVEL_ID","LEV_INIT_ID",
  627. "GEOMETRY_ID","NOMAP_ID","OBJECT_ID","MONSTER_ID","TRAP_ID","DOOR_ID",
  628. "DRAWBRIDGE_ID","MAZEWALK_ID","WALLIFY_ID","REGION_ID","FILLING",
  629. "RANDOM_OBJECTS_ID","RANDOM_MONSTERS_ID","RANDOM_PLACES_ID","ALTAR_ID",
  630. "LADDER_ID","STAIR_ID","NON_DIGGABLE_ID","NON_PASSWALL_ID","ROOM_ID",
  631. "PORTAL_ID","TELEPRT_ID","BRANCH_ID","LEV","CHANCE_ID","CORRIDOR_ID","GOLD_ID",
  632. "ENGRAVING_ID","FOUNTAIN_ID","POOL_ID","SINK_ID","NONE","RAND_CORRIDOR_ID",
  633. "DOOR_STATE","LIGHT_STATE","CURSE_TYPE","ENGRAVING_TYPE","DIRECTION",
  634. "RANDOM_TYPE","O_REGISTER","M_REGISTER","P_REGISTER","A_REGISTER","ALIGNMENT",
  635. "LEFT_OR_RIGHT","CENTER","TOP_OR_BOT","ALTAR_TYPE","UP_OR_DOWN","SUBROOM_ID",
  636. "NAME_ID","FLAGS_ID","FLAG_TYPE","MON_ATTITUDE","MON_ALERTNESS",
  637. "MON_APPEARANCE","STRING","MAP_ID",
  638. };
  639. char *yyrule[] = {
  640. "$accept : file",
  641. "file :",
  642. "file : levels",
  643. "levels : level",
  644. "levels : level levels",
  645. "level : maze_level",
  646. "level : room_level",
  647. "maze_level : maze_def flags lev_init messages regions",
  648. "room_level : level_def flags lev_init messages rreg_init rooms corridors_def",
  649. "level_def : LEVEL_ID ':' string",
  650. "lev_init :",
  651. "lev_init : LEV_INIT_ID ':' CHAR ',' CHAR ',' BOOLEAN ',' BOOLEAN ',' light_state ',' walled",
  652. "walled : BOOLEAN",
  653. "walled : RANDOM_TYPE",
  654. "flags :",
  655. "flags : FLAGS_ID ':' flag_list",
  656. "flag_list : FLAG_TYPE ',' flag_list",
  657. "flag_list : FLAG_TYPE",
  658. "messages :",
  659. "messages : message messages",
  660. "message : MESSAGE_ID ':' STRING",
  661. "rreg_init :",
  662. "rreg_init : rreg_init init_rreg",
  663. "init_rreg : RANDOM_OBJECTS_ID ':' object_list",
  664. "init_rreg : RANDOM_MONSTERS_ID ':' monster_list",
  665. "rooms :",
  666. "rooms : roomlist",
  667. "roomlist : aroom",
  668. "roomlist : aroom roomlist",
  669. "corridors_def : random_corridors",
  670. "corridors_def : corridors",
  671. "random_corridors : RAND_CORRIDOR_ID",
  672. "corridors :",
  673. "corridors : corridors corridor",
  674. "corridor : CORRIDOR_ID ':' corr_spec ',' corr_spec",
  675. "corridor : CORRIDOR_ID ':' corr_spec ',' INTEGER",
  676. "corr_spec : '(' INTEGER ',' DIRECTION ',' door_pos ')'",
  677. "aroom : room_def room_details",
  678. "aroom : subroom_def room_details",
  679. "subroom_def : SUBROOM_ID ':' room_type ',' light_state ',' subroom_pos ',' room_size ',' string roomfill",
  680. "room_def : ROOM_ID ':' room_type ',' light_state ',' room_pos ',' room_align ',' room_size roomfill",
  681. "roomfill :",
  682. "roomfill : ',' BOOLEAN",
  683. "room_pos : '(' INTEGER ',' INTEGER ')'",
  684. "room_pos : RANDOM_TYPE",
  685. "subroom_pos : '(' INTEGER ',' INTEGER ')'",
  686. "subroom_pos : RANDOM_TYPE",
  687. "room_align : '(' h_justif ',' v_justif ')'",
  688. "room_align : RANDOM_TYPE",
  689. "room_size : '(' INTEGER ',' INTEGER ')'",
  690. "room_size : RANDOM_TYPE",
  691. "room_details :",
  692. "room_details : room_details room_detail",
  693. "room_detail : room_name",
  694. "room_detail : room_chance",
  695. "room_detail : room_door",
  696. "room_detail : monster_detail",
  697. "room_detail : object_detail",
  698. "room_detail : trap_detail",
  699. "room_detail : altar_detail",
  700. "room_detail : fountain_detail",
  701. "room_detail : sink_detail",
  702. "room_detail : pool_detail",
  703. "room_detail : gold_detail",
  704. "room_detail : engraving_detail",
  705. "room_detail : stair_detail",
  706. "room_name : NAME_ID ':' string",
  707. "room_chance : CHANCE_ID ':' INTEGER",
  708. "room_door : DOOR_ID ':' secret ',' door_state ',' door_wall ',' door_pos",
  709. "secret : BOOLEAN",
  710. "secret : RANDOM_TYPE",
  711. "door_wall : DIRECTION",
  712. "door_wall : RANDOM_TYPE",
  713. "door_pos : INTEGER",
  714. "door_pos : RANDOM_TYPE",
  715. "maze_def : MAZE_ID ':' string ',' filling",
  716. "filling : CHAR",
  717. "filling : RANDOM_TYPE",
  718. "regions : aregion",
  719. "regions : aregion regions",
  720. "aregion : map_definition reg_init map_details",
  721. "map_definition : NOMAP_ID",
  722. "map_definition : map_geometry MAP_ID",
  723. "map_geometry : GEOMETRY_ID ':' h_justif ',' v_justif",
  724. "h_justif : LEFT_OR_RIGHT",
  725. "h_justif : CENTER",
  726. "v_justif : TOP_OR_BOT",
  727. "v_justif : CENTER",
  728. "reg_init :",
  729. "reg_init : reg_init init_reg",
  730. "init_reg : RANDOM_OBJECTS_ID ':' object_list",
  731. "init_reg : RANDOM_PLACES_ID ':' place_list",
  732. "init_reg : RANDOM_MONSTERS_ID ':' monster_list",
  733. "object_list : object",
  734. "object_list : object ',' object_list",
  735. "monster_list : monster",
  736. "monster_list : monster ',' monster_list",
  737. "place_list : place",
  738. "$$1 :",
  739. "place_list : place $$1 ',' place_list",
  740. "map_details :",
  741. "map_details : map_details map_detail",
  742. "map_detail : monster_detail",
  743. "map_detail : object_detail",
  744. "map_detail : door_detail",
  745. "map_detail : trap_detail",
  746. "map_detail : drawbridge_detail",
  747. "map_detail : region_detail",
  748. "map_detail : stair_region",
  749. "map_detail : portal_region",
  750. "map_detail : teleprt_region",
  751. "map_detail : branch_region",
  752. "map_detail : altar_detail",
  753. "map_detail : fountain_detail",
  754. "map_detail : mazewalk_detail",
  755. "map_detail : wallify_detail",
  756. "map_detail : ladder_detail",
  757. "map_detail : stair_detail",
  758. "map_detail : gold_detail",
  759. "map_detail : engraving_detail",
  760. "map_detail : diggable_detail",
  761. "map_detail : passwall_detail",
  762. "$$2 :",
  763. "monster_detail : MONSTER_ID ':' monster_c ',' m_name ',' coordinate $$2 monster_infos",
  764. "monster_infos :",
  765. "monster_infos : monster_infos monster_info",
  766. "monster_info : ',' string",
  767. "monster_info : ',' MON_ATTITUDE",
  768. "monster_info : ',' MON_ALERTNESS",
  769. "monster_info : ',' alignment",
  770. "monster_info : ',' MON_APPEARANCE string",
  771. "$$3 :",
  772. "object_detail : OBJECT_ID ':' object_c ',' o_name ',' coordinate $$3 object_infos",
  773. "object_infos :",
  774. "object_infos : ',' STRING ',' enchantment",
  775. "object_infos : ',' curse_state ',' enchantment ',' art_name",
  776. "curse_state : RANDOM_TYPE",
  777. "curse_state : CURSE_TYPE",
  778. "enchantment : INTEGER",
  779. "enchantment : RANDOM_TYPE",
  780. "door_detail : DOOR_ID ':' door_state ',' coordinate",
  781. "trap_detail : TRAP_ID ':' trap_name ',' coordinate",
  782. "drawbridge_detail : DRAWBRIDGE_ID ':' coordinate ',' DIRECTION ',' door_state",
  783. "mazewalk_detail : MAZEWALK_ID ':' coordinate ',' DIRECTION",
  784. "wallify_detail : WALLIFY_ID",
  785. "ladder_detail : LADDER_ID ':' coordinate ',' UP_OR_DOWN",
  786. "stair_detail : STAIR_ID ':' coordinate ',' UP_OR_DOWN",
  787. "$$4 :",
  788. "stair_region : STAIR_ID ':' lev_region $$4 ',' lev_region ',' UP_OR_DOWN",
  789. "$$5 :",
  790. "portal_region : PORTAL_ID ':' lev_region $$5 ',' lev_region ',' string",
  791. "$$6 :",
  792. "$$7 :",
  793. "teleprt_region : TELEPRT_ID ':' lev_region $$6 ',' lev_region $$7 teleprt_detail",
  794. "$$8 :",
  795. "branch_region : BRANCH_ID ':' lev_region $$8 ',' lev_region",
  796. "teleprt_detail :",
  797. "teleprt_detail : ',' UP_OR_DOWN",
  798. "lev_region : region",
  799. "lev_region : LEV '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'",
  800. "fountain_detail : FOUNTAIN_ID ':' coordinate",
  801. "sink_detail : SINK_ID ':' coordinate",
  802. "pool_detail : POOL_ID ':' coordinate",
  803. "diggable_detail : NON_DIGGABLE_ID ':' region",
  804. "passwall_detail : NON_PASSWALL_ID ':' region",
  805. "region_detail : REGION_ID ':' region ',' light_state ',' room_type prefilled",
  806. "altar_detail : ALTAR_ID ':' coordinate ',' alignment ',' altar_type",
  807. "gold_detail : GOLD_ID ':' amount ',' coordinate",
  808. "engraving_detail : ENGRAVING_ID ':' coordinate ',' engraving_type ',' string",
  809. "monster_c : monster",
  810. "monster_c : RANDOM_TYPE",
  811. "monster_c : m_register",
  812. "object_c : object",
  813. "object_c : RANDOM_TYPE",
  814. "object_c : o_register",
  815. "m_name : string",
  816. "m_name : RANDOM_TYPE",
  817. "o_name : string",
  818. "o_name : RANDOM_TYPE",
  819. "trap_name : string",
  820. "trap_name : RANDOM_TYPE",
  821. "room_type : string",
  822. "room_type : RANDOM_TYPE",
  823. "prefilled :",
  824. "prefilled : ',' FILLING",
  825. "prefilled : ',' FILLING ',' BOOLEAN",
  826. "coordinate : coord",
  827. "coordinate : p_register",
  828. "coordinate : RANDOM_TYPE",
  829. "door_state : DOOR_STATE",
  830. "door_state : RANDOM_TYPE",
  831. "light_state : LIGHT_STATE",
  832. "light_state : RANDOM_TYPE",
  833. "alignment : ALIGNMENT",
  834. "alignment : a_register",
  835. "alignment : RANDOM_TYPE",
  836. "altar_type : ALTAR_TYPE",
  837. "altar_type : RANDOM_TYPE",
  838. "p_register : P_REGISTER '[' INTEGER ']'",
  839. "o_register : O_REGISTER '[' INTEGER ']'",
  840. "m_register : M_REGISTER '[' INTEGER ']'",
  841. "a_register : A_REGISTER '[' INTEGER ']'",
  842. "place : coord",
  843. "monster : CHAR",
  844. "object : CHAR",
  845. "string : STRING",
  846. "art_name : STRING",
  847. "art_name : NONE",
  848. "amount : INTEGER",
  849. "amount : RANDOM_TYPE",
  850. "engraving_type : ENGRAVING_TYPE",
  851. "engraving_type : RANDOM_TYPE",
  852. "coord : '(' INTEGER ',' INTEGER ')'",
  853. "region : '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'",
  854. };
  855. #endif
  856. #ifdef YYSTACKSIZE
  857. #undef YYMAXDEPTH
  858. #define YYMAXDEPTH YYSTACKSIZE
  859. #else
  860. #ifdef YYMAXDEPTH
  861. #define YYSTACKSIZE YYMAXDEPTH
  862. #else
  863. #define YYSTACKSIZE 500
  864. #define YYMAXDEPTH 500
  865. #endif
  866. #endif
  867. int yydebug;
  868. int yynerrs;
  869. int yyerrflag;
  870. int yychar;
  871. short *yyssp;
  872. YYSTYPE *yyvsp;
  873. YYSTYPE yyval;
  874. YYSTYPE yylval;
  875. short yyss[YYSTACKSIZE];
  876. YYSTYPE yyvs[YYSTACKSIZE];
  877. #define yystacksize YYSTACKSIZE
  878. #define YYABORT goto yyabort
  879. #define YYREJECT goto yyabort
  880. #define YYACCEPT goto yyaccept
  881. #define YYERROR goto yyerrlab
  882. int
  883. yyparse()
  884. {
  885.     register int yym, yyn, yystate;
  886. #if YYDEBUG
  887.     register char *yys;
  888.     extern char *getenv();
  889.  
  890.     if ((yys = getenv("YYDEBUG")) != 0)
  891.     {
  892.         yyn = *yys;
  893.         if (yyn >= '0' && yyn <= '9')
  894.             yydebug = yyn - '0';
  895.     }
  896. #endif
  897.  
  898.     yynerrs = 0;
  899.     yyerrflag = 0;
  900.     yychar = (-1);
  901.  
  902.     yyssp = yyss;
  903.     yyvsp = yyvs;
  904.     *yyssp = yystate = 0;
  905.  
  906. yyloop:
  907.     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
  908.     if (yychar < 0)
  909.     {
  910.         if ((yychar = yylex()) < 0) yychar = 0;
  911. #if YYDEBUG
  912.         if (yydebug)
  913.         {
  914.             yys = 0;
  915.             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  916.             if (!yys) yys = "illegal-symbol";
  917.             printf("%sdebug: state %d, reading %d (%s)\n",
  918.                     YYPREFIX, yystate, yychar, yys);
  919.         }
  920. #endif
  921.     }
  922.     if ((yyn = yysindex[yystate]) != 0 && (yyn += yychar) >= 0 &&
  923.             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  924.     {
  925. #if YYDEBUG
  926.         if (yydebug)
  927.             printf("%sdebug: state %d, shifting to state %d\n",
  928.                     YYPREFIX, yystate, yytable[yyn]);
  929. #endif
  930.         if (yyssp >= yyss + yystacksize - 1)
  931.         {
  932.             goto yyoverflow;
  933.         }
  934.         *++yyssp = yystate = yytable[yyn];
  935.         *++yyvsp = yylval;
  936.         yychar = (-1);
  937.         if (yyerrflag > 0)  --yyerrflag;
  938.         goto yyloop;
  939.     }
  940.     if ((yyn = yyrindex[yystate]) != 0 && (yyn += yychar) >= 0 &&
  941.             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
  942.     {
  943.         yyn = yytable[yyn];
  944.         goto yyreduce;
  945.     }
  946.     if (yyerrflag) goto yyinrecovery;
  947. #ifdef lint
  948.     goto yynewerror;
  949. #endif
  950. yynewerror:
  951.     yyerror("syntax error");
  952. #ifdef lint
  953.     goto yyerrlab;
  954. #endif
  955. yyerrlab:
  956.     ++yynerrs;
  957. yyinrecovery:
  958.     if (yyerrflag < 3)
  959.     {
  960.         yyerrflag = 3;
  961.         for (;;)
  962.         {
  963.             if ((yyn = yysindex[*yyssp]) != 0 && (yyn += YYERRCODE) >= 0 &&
  964.                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
  965.             {
  966. #if YYDEBUG
  967.                 if (yydebug)
  968.                     printf("%sdebug: state %d, error recovery shifting\
  969.  to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
  970. #endif
  971.                 if (yyssp >= yyss + yystacksize - 1)
  972.                 {
  973.                     goto yyoverflow;
  974.                 }
  975.                 *++yyssp = yystate = yytable[yyn];
  976.                 *++yyvsp = yylval;
  977.                 goto yyloop;
  978.             }
  979.             else
  980.             {
  981. #if YYDEBUG
  982.                 if (yydebug)
  983.                     printf("%sdebug: error recovery discarding state %d\n",
  984.                             YYPREFIX, *yyssp);
  985. #endif
  986.                 if (yyssp <= yyss) goto yyabort;
  987.                 --yyssp;
  988.                 --yyvsp;
  989.             }
  990.         }
  991.     }
  992.     else
  993.     {
  994.         if (yychar == 0) goto yyabort;
  995. #if YYDEBUG
  996.         if (yydebug)
  997.         {
  998.             yys = 0;
  999.             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  1000.             if (!yys) yys = "illegal-symbol";
  1001.             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
  1002.                     YYPREFIX, yystate, yychar, yys);
  1003.         }
  1004. #endif
  1005.         yychar = (-1);
  1006.         goto yyloop;
  1007.     }
  1008. yyreduce:
  1009. #if YYDEBUG
  1010.     if (yydebug)
  1011.         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
  1012.                 YYPREFIX, yystate, yyn, yyrule[yyn]);
  1013. #endif
  1014.     yym = yylen[yyn];
  1015.     yyval = yyvsp[1-yym];
  1016.     switch (yyn)
  1017.     {
  1018. case 7:
  1019. {
  1020.               int fout, i;
  1021.  
  1022.             if (fatal_error > 0) {
  1023.                 fprintf(stderr,
  1024.                   "%s : %d errors detected. No output created!\n",
  1025.                     fname, fatal_error);
  1026.             } else {
  1027.                 char lbuf[20];
  1028.                 Strcpy(lbuf, yyvsp[-4].map);
  1029.                 Strcat(lbuf, LEV_EXT);
  1030. #ifdef THINK_C
  1031.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY);
  1032. #else
  1033.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY, OMASK);
  1034. #endif
  1035.                 if (fout < 0) {
  1036.                     yyerror("Can't open output file!!");
  1037.                     exit(1);
  1038.                 }
  1039.                 maze.flags = yyvsp[-3].i;
  1040.                 memcpy(&(maze.init_lev), &(init_lev),
  1041.                        sizeof(lev_init));
  1042.                 maze.numpart = npart;
  1043.                 maze.parts = NewTab(mazepart, npart);
  1044.                 for(i=0;i<npart;i++)
  1045.                     maze.parts[i] = tmppart[i];
  1046.                 write_maze(fout, &maze);
  1047.                 (void) close(fout);
  1048.                 npart = 0;
  1049.             }
  1050.           }
  1051. break;
  1052. case 8:
  1053. {
  1054.             int fout, i;
  1055.  
  1056.             if (fatal_error > 0) {
  1057.                 fprintf(stderr,
  1058.                   "%s : %d errors detected. No output created!\n",
  1059.                     fname, fatal_error);
  1060.             } else {
  1061.                 char lbuf[20];
  1062.                 Strcpy(lbuf, yyvsp[-6].map);
  1063.                 Strcat(lbuf, LEV_EXT);
  1064. #ifdef THINK_C
  1065.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY);
  1066. #else
  1067.                 fout = open(lbuf, O_WRONLY|O_CREAT|O_BINARY, OMASK);
  1068. #endif
  1069.                 if (fout < 0) {
  1070.                     yyerror("Can't open output file!!");
  1071.                     exit(1);
  1072.                 }
  1073.                 special_lev.flags = yyvsp[-5].i;
  1074.                 memcpy(&(special_lev.init_lev), &(init_lev),
  1075.                        sizeof(lev_init));
  1076.                 special_lev.nroom = nrooms;
  1077.                 special_lev.rooms = NewTab(room, nrooms);
  1078.                 for(i=0; i<nrooms; i++)
  1079.                     special_lev.rooms[i] = tmproom[i];
  1080.                 special_lev.ncorr = ncorridor;
  1081.                 special_lev.corrs = NewTab(corridor, ncorridor);
  1082.                 for(i=0; i<ncorridor; i++)
  1083.                     special_lev.corrs[i] = tmpcor[i];
  1084.                 if (check_subrooms())
  1085.                     write_lev(fout, &special_lev);
  1086.                 free_rooms(special_lev.rooms,special_lev.nroom);
  1087.                 nrooms = 0;
  1088.                 ncorridor = 0;
  1089.                 (void) close(fout);
  1090.             }
  1091.           }
  1092. break;
  1093. case 9:
  1094. {
  1095.             if (index(yyvsp[0].map, '.'))
  1096.                 yyerror("Invalid dot ('.') in level name.");
  1097.             if (strlen(yyvsp[0].map) > 8)
  1098.                 yyerror("Level names limited to 8 characters.");
  1099.             yyval.map = yyvsp[0].map;
  1100.             special_lev.nrobjects = 0;
  1101.             special_lev.nrmonst = 0;
  1102.           }
  1103. break;
  1104. case 10:
  1105. {
  1106.             init_lev.init_present = FALSE;
  1107.             yyval.i = 0;
  1108.           }
  1109. break;
  1110. case 11:
  1111. {
  1112.             init_lev.init_present = TRUE;
  1113.             if((init_lev.fg = what_map_char(yyvsp[-10].i)) == INVALID_TYPE)
  1114.                 yyerror("Invalid foreground type.");
  1115.             if((init_lev.bg = what_map_char(yyvsp[-8].i)) == INVALID_TYPE)
  1116.                 yyerror("Invalid background type.");
  1117.             init_lev.smoothed = yyvsp[-6].i;
  1118.             init_lev.joined = yyvsp[-4].i;
  1119.             init_lev.lit = yyvsp[-2].i;
  1120.             init_lev.walled = yyvsp[0].i;
  1121.             yyval.i = 1;
  1122.           }
  1123. break;
  1124. case 14:
  1125. {
  1126.             yyval.i = 0;
  1127.           }
  1128. break;
  1129. case 15:
  1130. {
  1131.             yyval.i = lev_flags;
  1132.             lev_flags = 0;    /* clear for next user */
  1133.           }
  1134. break;
  1135. case 16:
  1136. {
  1137.             lev_flags |= yyvsp[-2].i;
  1138.           }
  1139. break;
  1140. case 17:
  1141. {
  1142.             lev_flags |= yyvsp[0].i;
  1143.           }
  1144. break;
  1145. case 20:
  1146. {
  1147.             int i, j;
  1148.  
  1149.             i = strlen(yyvsp[0].map) + 1;
  1150.             j = tmpmessage[0] ? strlen(tmpmessage) : 0;
  1151.             if(i+j > 255) {
  1152.                yyerror("Message string too long (>256 characters)");
  1153.             } else {
  1154.                 if(j) tmpmessage[j++] = '\n';
  1155.                 strncpy(tmpmessage+j, yyvsp[0].map, i-1);
  1156.                 tmpmessage[j+i-1] = 0;
  1157.             }
  1158.           }
  1159. break;
  1160. case 23:
  1161. {
  1162.             if(special_lev.nrobjects) {
  1163.                 yyerror("Object registers already initialized!");
  1164.             } else {
  1165.                 special_lev.nrobjects = n_olist;
  1166.                 special_lev.robjects = (char *) alloc(n_olist);
  1167.                 (void) memcpy((genericptr_t)special_lev.robjects,
  1168.                       (genericptr_t)olist, n_olist);
  1169.             }
  1170.           }
  1171. break;
  1172. case 24:
  1173. {
  1174.             if(special_lev.nrmonst) {
  1175.                 yyerror("Monster registers already initialized!");
  1176.             } else {
  1177.                 special_lev.nrmonst = n_mlist;
  1178.                 special_lev.rmonst = (char *) alloc(n_mlist);
  1179.                 (void) memcpy((genericptr_t)special_lev.rmonst,
  1180.                       (genericptr_t)mlist, n_mlist);
  1181.               }
  1182.           }
  1183. break;
  1184. case 25:
  1185. {
  1186.             tmproom[nrooms] = New(room);
  1187.             (void) memset((genericptr_t) tmproom[nrooms], 0,
  1188.                     sizeof *tmproom[nrooms]);
  1189.             tmproom[nrooms]->name = (char *) 0;
  1190.             tmproom[nrooms]->parent = (char *) 0;
  1191.             tmproom[nrooms]->rtype = 0;
  1192.             tmproom[nrooms]->rlit = 0;
  1193.             tmproom[nrooms]->xalign = ERR;
  1194.             tmproom[nrooms]->yalign = ERR;
  1195.             tmproom[nrooms]->x = 0;
  1196.             tmproom[nrooms]->y = 0;
  1197.             tmproom[nrooms]->w = 2;
  1198.             tmproom[nrooms]->h = 2;
  1199.             in_room = 1;
  1200.           }
  1201. break;
  1202. case 31:
  1203. {
  1204.             tmpcor[0] = New(corridor);
  1205.             tmpcor[0]->src.room = -1;
  1206.             ncorridor = 1;
  1207.           }
  1208. break;
  1209. case 34:
  1210. {
  1211.             tmpcor[ncorridor] = New(corridor);
  1212.             tmpcor[ncorridor]->src.room = yyvsp[-2].corpos.room;
  1213.             tmpcor[ncorridor]->src.wall = yyvsp[-2].corpos.wall;
  1214.             tmpcor[ncorridor]->src.door = yyvsp[-2].corpos.door;
  1215.             tmpcor[ncorridor]->dest.room = yyvsp[0].corpos.room;
  1216.             tmpcor[ncorridor]->dest.wall = yyvsp[0].corpos.wall;
  1217.             tmpcor[ncorridor]->dest.door = yyvsp[0].corpos.door;
  1218.             ncorridor++;
  1219.           }
  1220. break;
  1221. case 35:
  1222. {
  1223.             tmpcor[ncorridor]->src.room = yyvsp[-2].corpos.room;
  1224.             tmpcor[ncorridor]->src.wall = yyvsp[-2].corpos.wall;
  1225.             tmpcor[ncorridor]->src.door = yyvsp[-2].corpos.door;
  1226.             tmpcor[ncorridor]->dest.room = -1;
  1227.             tmpcor[ncorridor]->dest.wall = yyvsp[0].i;
  1228.             ncorridor++;
  1229.           }
  1230. break;
  1231. case 36:
  1232. {
  1233.             if (yyvsp[-5].i >= nrooms)
  1234.                 yyerror("Wrong room number!");
  1235.             yyval.corpos.room = yyvsp[-5].i;
  1236.             yyval.corpos.wall = yyvsp[-3].i;
  1237.             yyval.corpos.door = yyvsp[-1].i;
  1238.           }
  1239. break;
  1240. case 37:
  1241. {
  1242.             store_room();
  1243.           }
  1244. break;
  1245. case 38:
  1246. {
  1247.             store_room();
  1248.           }
  1249. break;
  1250. case 39:
  1251. {
  1252.             tmproom[nrooms] = New(room);
  1253.             (void) memset((genericptr_t) tmproom[nrooms], 0,
  1254.                     sizeof *tmproom[nrooms]);
  1255.             tmproom[nrooms]->parent = dup_string(yyvsp[-1].map);
  1256.             tmproom[nrooms]->name = (char *) 0;
  1257.             tmproom[nrooms]->rtype = yyvsp[-9].i;
  1258.             tmproom[nrooms]->rlit = yyvsp[-7].i;
  1259.             tmproom[nrooms]->filled = yyvsp[0].i;
  1260.             tmproom[nrooms]->xalign = ERR;
  1261.             tmproom[nrooms]->yalign = ERR;
  1262.             tmproom[nrooms]->x = current_coord.x;
  1263.             tmproom[nrooms]->y = current_coord.y;
  1264.             tmproom[nrooms]->w = current_size.width;
  1265.             tmproom[nrooms]->h = current_size.height;
  1266.             in_room = 1;
  1267.           }
  1268. break;
  1269. case 40:
  1270. {
  1271.             tmproom[nrooms] = New(room);
  1272.             (void) memset((genericptr_t) tmproom[nrooms], 0,
  1273.                     sizeof *tmproom[nrooms]);
  1274.             tmproom[nrooms]->name = (char *) 0;
  1275.             tmproom[nrooms]->parent = (char *) 0;
  1276.             tmproom[nrooms]->rtype = yyvsp[-9].i;
  1277.             tmproom[nrooms]->rlit = yyvsp[-7].i;
  1278.             tmproom[nrooms]->filled = yyvsp[0].i;
  1279.             tmproom[nrooms]->xalign = current_align.x;
  1280.             tmproom[nrooms]->yalign = current_align.y;
  1281.             tmproom[nrooms]->x = current_coord.x;
  1282.             tmproom[nrooms]->y = current_coord.y;
  1283.             tmproom[nrooms]->w = current_size.width;
  1284.             tmproom[nrooms]->h = current_size.height;
  1285.             in_room = 1;
  1286.           }
  1287. break;
  1288. case 41:
  1289. {
  1290.             yyval.i = 1;
  1291.           }
  1292. break;
  1293. case 42:
  1294. {
  1295.             yyval.i = yyvsp[0].i;
  1296.           }
  1297. break;
  1298. case 43:
  1299. {
  1300.             if ( yyvsp[-3].i < 1 || yyvsp[-3].i > 5 ||
  1301.                 yyvsp[-1].i < 1 || yyvsp[-1].i > 5 ) {
  1302.                 yyerror("Room position should be between 1 & 5!");
  1303.             } else {
  1304.                 current_coord.x = yyvsp[-3].i;
  1305.                 current_coord.y = yyvsp[-1].i;
  1306.             }
  1307.           }
  1308. break;
  1309. case 44:
  1310. {
  1311.             current_coord.x = current_coord.y = ERR;
  1312.           }
  1313. break;
  1314. case 45:
  1315. {
  1316.             if ( yyvsp[-3].i < 0 || yyvsp[-1].i < 0) {
  1317.                 yyerror("Invalid subroom position !");
  1318.             } else {
  1319.                 current_coord.x = yyvsp[-3].i;
  1320.                 current_coord.y = yyvsp[-1].i;
  1321.             }
  1322.           }
  1323. break;
  1324. case 46:
  1325. {
  1326.             current_coord.x = current_coord.y = ERR;
  1327.           }
  1328. break;
  1329. case 47:
  1330. {
  1331.             current_align.x = yyvsp[-3].i;
  1332.             current_align.y = yyvsp[-1].i;
  1333.           }
  1334. break;
  1335. case 48:
  1336. {
  1337.             current_align.x = current_align.y = ERR;
  1338.           }
  1339. break;
  1340. case 49:
  1341. {
  1342.             current_size.width = yyvsp[-3].i;
  1343.             current_size.height = yyvsp[-1].i;
  1344.           }
  1345. break;
  1346. case 50:
  1347. {
  1348.             current_size.height = current_size.width = ERR;
  1349.           }
  1350. break;
  1351. case 66:
  1352. {
  1353.             if (tmproom[nrooms]->name)
  1354.                 yyerror("This room already has a name!");
  1355.             else
  1356.                 tmproom[nrooms]->name = dup_string(yyvsp[0].map);
  1357.           }
  1358. break;
  1359. case 67:
  1360. {
  1361.             if (tmproom[nrooms]->chance)
  1362.                 yyerror("This room already assigned a chance!");
  1363.             else if (tmproom[nrooms]->rtype == OROOM)
  1364.                 yyerror("Only typed rooms can have a chance!");
  1365.             else if (yyvsp[0].i < 1 || yyvsp[0].i > 99)
  1366.                 yyerror("The chance is supposed to be precentile.");
  1367.             else
  1368.                 tmproom[nrooms]->chance = yyvsp[0].i;
  1369.            }
  1370. break;
  1371. case 68:
  1372. {
  1373.             /* ERR means random here */
  1374.             if (yyvsp[-2].i == ERR && yyvsp[0].i != ERR) {
  1375.              yyerror("If the door wall is random, so must be its pos!");
  1376.             } else {
  1377.                 tmprdoor[ndoor] = New(room_door);
  1378.                 tmprdoor[ndoor]->secret = yyvsp[-6].i;
  1379.                 tmprdoor[ndoor]->mask = yyvsp[-4].i;
  1380.                 tmprdoor[ndoor]->wall = yyvsp[-2].i;
  1381.                 tmprdoor[ndoor]->pos = yyvsp[0].i;
  1382.                 ndoor++;
  1383.             }
  1384.           }
  1385. break;
  1386. case 75:
  1387. {
  1388.             maze.filling = yyvsp[0].i;
  1389.             if (index(yyvsp[-2].map, '.'))
  1390.                 yyerror("Invalid dot ('.') in level name.");
  1391.             if (strlen(yyvsp[-2].map) > 8)
  1392.                 yyerror("Level names limited to 8 characters.");
  1393.             yyval.map = yyvsp[-2].map;
  1394.             in_room = 0;
  1395.           }
  1396. break;
  1397. case 76:
  1398. {
  1399.             yyval.i = get_floor_type((char)yyvsp[0].i);
  1400.           }
  1401. break;
  1402. case 77:
  1403. {
  1404.             yyval.i = -1;
  1405.           }
  1406. break;
  1407. case 80:
  1408. {
  1409.             store_part();
  1410.           }
  1411. break;
  1412. case 81:
  1413. {
  1414.             tmppart[npart] = New(mazepart);
  1415.             tmppart[npart]->halign = 1;
  1416.             tmppart[npart]->valign = 1;
  1417.             tmppart[npart]->nrobjects = 0;
  1418.             tmppart[npart]->nloc = 0;
  1419.             tmppart[npart]->nrmonst = 0;
  1420.             tmppart[npart]->xsize = 1;
  1421.             tmppart[npart]->ysize = 1;
  1422.             tmppart[npart]->map = (char **) alloc(sizeof(char *));
  1423.             tmppart[npart]->map[0] = (char *) alloc(1);
  1424.             tmppart[npart]->map[0][0] = STONE;
  1425.             max_x_map = COLNO-1;
  1426.             max_y_map = ROWNO;
  1427.           }
  1428. break;
  1429. case 82:
  1430. {
  1431.             tmppart[npart] = New(mazepart);
  1432.             tmppart[npart]->halign = yyvsp[-1].i % 10;
  1433.             tmppart[npart]->valign = yyvsp[-1].i / 10;
  1434.             tmppart[npart]->nrobjects = 0;
  1435.             tmppart[npart]->nloc = 0;
  1436.             tmppart[npart]->nrmonst = 0;
  1437.             scan_map(yyvsp[0].map);
  1438.           }
  1439. break;
  1440. case 83:
  1441. {
  1442.             yyval.i = yyvsp[-2].i + (yyvsp[0].i * 10);
  1443.           }
  1444. break;
  1445. case 90:
  1446. {
  1447.             if (tmppart[npart]->nrobjects) {
  1448.                 yyerror("Object registers already initialized!");
  1449.             } else {
  1450.                 tmppart[npart]->robjects = (char *)alloc(n_olist);
  1451.                 (void) memcpy((genericptr_t)tmppart[npart]->robjects,
  1452.                       (genericptr_t)olist, n_olist);
  1453.                 tmppart[npart]->nrobjects = n_olist;
  1454.             }
  1455.           }
  1456. break;
  1457. case 91:
  1458. {
  1459.             if (tmppart[npart]->nloc) {
  1460.                 yyerror("Location registers already initialized!");
  1461.             } else {
  1462.                 register int i;
  1463.                 tmppart[npart]->rloc_x = (char *) alloc(n_plist);
  1464.                 tmppart[npart]->rloc_y = (char *) alloc(n_plist);
  1465.                 for(i=0;i<n_plist;i++) {
  1466.                 tmppart[npart]->rloc_x[i] = plist[i].x;
  1467.                 tmppart[npart]->rloc_y[i] = plist[i].y;
  1468.                 }
  1469.                 tmppart[npart]->nloc = n_plist;
  1470.             }
  1471.           }
  1472. break;
  1473. case 92:
  1474. {
  1475.             if (tmppart[npart]->nrmonst) {
  1476.                 yyerror("Monster registers already initialized!");
  1477.             } else {
  1478.                 tmppart[npart]->rmonst = (char *) alloc(n_mlist);
  1479.                 (void) memcpy((genericptr_t)tmppart[npart]->rmonst,
  1480.                       (genericptr_t)mlist, n_mlist);
  1481.                 tmppart[npart]->nrmonst = n_mlist;
  1482.             }
  1483.           }
  1484. break;
  1485. case 93:
  1486. {
  1487.             if (n_olist < MAX_REGISTERS)
  1488.                 olist[n_olist++] = yyvsp[0].i;
  1489.             else
  1490.                 yyerror("Object list too long!");
  1491.           }
  1492. break;
  1493. case 94:
  1494. {
  1495.             if (n_olist < MAX_REGISTERS)
  1496.                 olist[n_olist++] = yyvsp[-2].i;
  1497.             else
  1498.                 yyerror("Object list too long!");
  1499.           }
  1500. break;
  1501. case 95:
  1502. {
  1503.             if (n_mlist < MAX_REGISTERS)
  1504.                 mlist[n_mlist++] = yyvsp[0].i;
  1505.             else
  1506.                 yyerror("Monster list too long!");
  1507.           }
  1508. break;
  1509. case 96:
  1510. {
  1511.             if (n_mlist < MAX_REGISTERS)
  1512.                 mlist[n_mlist++] = yyvsp[-2].i;
  1513.             else
  1514.                 yyerror("Monster list too long!");
  1515.           }
  1516. break;
  1517. case 97:
  1518. {
  1519.             if (n_plist < MAX_REGISTERS)
  1520.                 plist[n_plist++] = current_coord;
  1521.             else
  1522.                 yyerror("Location list too long!");
  1523.           }
  1524. break;
  1525. case 98:
  1526. {
  1527.             if (n_plist < MAX_REGISTERS)
  1528.                 plist[n_plist++] = current_coord;
  1529.             else
  1530.                 yyerror("Location list too long!");
  1531.           }
  1532. break;
  1533. case 122:
  1534. {
  1535.             tmpmonst[nmons] = New(monster);
  1536.             tmpmonst[nmons]->x = current_coord.x;
  1537.             tmpmonst[nmons]->y = current_coord.y;
  1538.             tmpmonst[nmons]->class = yyvsp[-4].i;
  1539.             tmpmonst[nmons]->peaceful = -1; /* no override */
  1540.             tmpmonst[nmons]->asleep = -1;
  1541.             tmpmonst[nmons]->align = - MAX_REGISTERS - 2;
  1542.             tmpmonst[nmons]->name = (char *) 0;
  1543.             tmpmonst[nmons]->appear = 0;
  1544.             tmpmonst[nmons]->appear_as = (char *) 0;
  1545.             if (!in_room)
  1546.                 check_coord(current_coord.x, current_coord.y,
  1547.                     "Monster");
  1548.             if (!yyvsp[-2].map)
  1549.                 tmpmonst[nmons]->id = -1;
  1550.             else {
  1551.                 int token = get_monster_id(yyvsp[-2].map, (char) yyvsp[-4].i);
  1552.                 if (token == ERR) {
  1553.                     yywarning("Illegal monster name!  Making random monster.");
  1554.                     tmpmonst[nmons]->id = -1;
  1555.                 } else
  1556.                     tmpmonst[nmons]->id = token;
  1557.             }
  1558.           }
  1559. break;
  1560. case 123:
  1561. {
  1562.             nmons++;
  1563.           }
  1564. break;
  1565. case 126:
  1566. {
  1567.             tmpmonst[nmons]->name = dup_string(yyvsp[0].map);
  1568.           }
  1569. break;
  1570. case 127:
  1571. {
  1572.             tmpmonst[nmons]->peaceful = yyvsp[0].i;
  1573.           }
  1574. break;
  1575. case 128:
  1576. {
  1577.             tmpmonst[nmons]->asleep = yyvsp[0].i;
  1578.           }
  1579. break;
  1580. case 129:
  1581. {
  1582.             tmpmonst[nmons]->align = yyvsp[0].i;
  1583.           }
  1584. break;
  1585. case 130:
  1586. {
  1587.             tmpmonst[nmons]->appear = yyvsp[-1].i;
  1588.             tmpmonst[nmons]->appear_as = dup_string(yyvsp[0].map);
  1589.           }
  1590. break;
  1591. case 131:
  1592. {
  1593.             tmpobj[nobj] = New(object);
  1594.             tmpobj[nobj]->x = current_coord.x;
  1595.             tmpobj[nobj]->y = current_coord.y;
  1596.             tmpobj[nobj]->class = yyvsp[-4].i;
  1597.             tmpobj[nobj]->corpsenm = -1;    /* init as none */
  1598.             tmpobj[nobj]->curse_state = -1;
  1599.             tmpobj[nobj]->name = (char *) 0;
  1600.             if (!in_room)
  1601.                 check_coord(current_coord.x, current_coord.y,
  1602.                     "Object");
  1603.             if (!yyvsp[-2].map)
  1604.                 tmpobj[nobj]->id = -1;
  1605.             else {
  1606.                 int token = get_object_id(yyvsp[-2].map);
  1607.                 if (token == ERR) {
  1608.                     yywarning("Illegal object name!  Making random object.");
  1609.                     tmpobj[nobj]->id = -1;
  1610.                 } else
  1611.                     tmpobj[nobj]->id = token;
  1612.             }
  1613.           }
  1614. break;
  1615. case 132:
  1616. {
  1617.             nobj++;
  1618.           }
  1619. break;
  1620. case 133:
  1621. {
  1622.             tmpobj[nobj]->spe = -127;
  1623.           }
  1624. break;
  1625. case 134:
  1626. {
  1627.             int token = get_monster_id(yyvsp[-2].map, (char)0);
  1628.             if (token == ERR)    /* "random" */
  1629.                 tmpobj[nobj]->corpsenm = -2;
  1630.             else
  1631.                 tmpobj[nobj]->corpsenm = token;
  1632.             tmpobj[nobj]->spe = yyvsp[0].i;
  1633.           }
  1634. break;
  1635. case 135:
  1636. {
  1637.             tmpobj[nobj]->curse_state = yyvsp[-4].i;
  1638.             tmpobj[nobj]->spe = yyvsp[-2].i;
  1639.             if (yyvsp[0].map)
  1640.                 tmpobj[nobj]->name = dup_string(yyvsp[0].map);
  1641.             else
  1642.                 tmpobj[nobj]->name = (char *) 0;
  1643.           }
  1644. break;
  1645. case 139:
  1646. {
  1647.             yyval.i = -127;
  1648.           }
  1649. break;
  1650. case 140:
  1651. {
  1652.             tmpdoor[ndoor] = New(door);
  1653.             tmpdoor[ndoor]->x = current_coord.x;
  1654.             tmpdoor[ndoor]->y = current_coord.y;
  1655.             tmpdoor[ndoor]->mask = yyvsp[-2].i;
  1656.             if(current_coord.x >= 0 && current_coord.y >= 0 &&
  1657.                tmpmap[current_coord.y][current_coord.x] != DOOR &&
  1658.                tmpmap[current_coord.y][current_coord.x] != SDOOR)
  1659.                 yyerror("Door decl doesn't match the map");
  1660.             ndoor++;
  1661.           }
  1662. break;
  1663. case 141:
  1664. {
  1665.             tmptrap[ntrap] = New(trap);
  1666.             tmptrap[ntrap]->x = current_coord.x;
  1667.             tmptrap[ntrap]->y = current_coord.y;
  1668.             tmptrap[ntrap]->type = yyvsp[-2].i;
  1669.             if (!in_room)
  1670.                 check_coord(current_coord.x, current_coord.y,
  1671.                     "Trap");
  1672.             ntrap++;
  1673.           }
  1674. break;
  1675. case 142:
  1676. {
  1677.                 int x, y, dir;
  1678.  
  1679.             tmpdb[ndb] = New(drawbridge);
  1680.             x = tmpdb[ndb]->x = current_coord.x;
  1681.             y = tmpdb[ndb]->y = current_coord.y;
  1682.             /* convert dir from a DIRECTION to a DB_DIR */
  1683.             dir = yyvsp[-2].i;
  1684.             switch(dir) {
  1685.             case W_NORTH: dir = DB_NORTH; y--; break;
  1686.             case W_SOUTH: dir = DB_SOUTH; y++; break;
  1687.             case W_EAST:  dir = DB_EAST;  x++; break;
  1688.             case W_WEST:  dir = DB_WEST;  x--; break;
  1689.             default:
  1690.                 yyerror("Invalid drawbridge direction");
  1691.                 break;
  1692.             }
  1693.             tmpdb[ndb]->dir = dir;
  1694.             if (current_coord.x >= 0 && current_coord.y >= 0 &&
  1695.                 !IS_WALL(tmpmap[y][x])) {
  1696.                 char ebuf[60];
  1697.                 Sprintf(ebuf,
  1698.                     "Wall needed for drawbridge (%02d, %02d)",
  1699.                     current_coord.x, current_coord.y);
  1700.                 yyerror(ebuf);
  1701.             }
  1702.  
  1703.             if ( yyvsp[0].i == D_ISOPEN )
  1704.                 tmpdb[ndb]->db_open = 1;
  1705.             else if ( yyvsp[0].i == D_CLOSED )
  1706.                 tmpdb[ndb]->db_open = 0;
  1707.             else
  1708.                 yyerror("A drawbridge can only be open or closed!");
  1709.             ndb++;
  1710.            }
  1711. break;
  1712. case 143:
  1713. {
  1714.             tmpwalk[nwalk] = New(walk);
  1715.             tmpwalk[nwalk]->x = current_coord.x;
  1716.             tmpwalk[nwalk]->y = current_coord.y;
  1717.             tmpwalk[nwalk]->dir = yyvsp[0].i;
  1718.             nwalk++;
  1719.           }
  1720. break;
  1721. case 144:
  1722. {
  1723.             wallify_map();
  1724.           }
  1725. break;
  1726. case 145:
  1727. {
  1728.             tmplad[nlad] = New(lad);
  1729.             tmplad[nlad]->x = current_coord.x;
  1730.             tmplad[nlad]->y = current_coord.y;
  1731.             tmplad[nlad]->up = yyvsp[0].i;
  1732.             if (!in_room)
  1733.                 check_coord(current_coord.x, current_coord.y,
  1734.                     "Ladder");
  1735.             nlad++;
  1736.           }
  1737. break;
  1738. case 146:
  1739. {
  1740.             tmpstair[nstair] = New(stair);
  1741.             tmpstair[nstair]->x = current_coord.x;
  1742.             tmpstair[nstair]->y = current_coord.y;
  1743.             tmpstair[nstair]->up = yyvsp[0].i;
  1744.             if (!in_room)
  1745.                 check_coord(current_coord.x, current_coord.y,
  1746.                     "Stairway");
  1747.             nstair++;
  1748.           }
  1749. break;
  1750. case 147:
  1751. {
  1752.             tmplreg[nlreg] = New(lev_region);
  1753.             tmplreg[nlreg]->in_islev = yyvsp[0].i;
  1754.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1755.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1756.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1757.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1758.           }
  1759. break;
  1760. case 148:
  1761. {
  1762.             tmplreg[nlreg]->del_islev = yyvsp[-2].i;
  1763.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1764.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1765.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1766.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1767.             if(yyvsp[0].i)
  1768.                 tmplreg[nlreg]->rtype = LR_UPSTAIR;
  1769.             else
  1770.                 tmplreg[nlreg]->rtype = LR_DOWNSTAIR;
  1771.             tmplreg[nlreg]->rname = 0;
  1772.             nlreg++;
  1773.           }
  1774. break;
  1775. case 149:
  1776. {
  1777.             tmplreg[nlreg] = New(lev_region);
  1778.             tmplreg[nlreg]->in_islev = yyvsp[0].i;
  1779.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1780.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1781.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1782.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1783.           }
  1784. break;
  1785. case 150:
  1786. {
  1787.             tmplreg[nlreg]->del_islev = yyvsp[-2].i;
  1788.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1789.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1790.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1791.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1792.             tmplreg[nlreg]->rtype = LR_PORTAL;
  1793.             tmplreg[nlreg]->rname = yyvsp[0].map;
  1794.             nlreg++;
  1795.           }
  1796. break;
  1797. case 151:
  1798. {
  1799.             tmplreg[nlreg] = New(lev_region);
  1800.             tmplreg[nlreg]->in_islev = yyvsp[0].i;
  1801.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1802.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1803.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1804.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1805.           }
  1806. break;
  1807. case 152:
  1808. {
  1809.             tmplreg[nlreg]->del_islev = yyvsp[0].i;
  1810.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1811.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1812.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1813.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1814.           }
  1815. break;
  1816. case 153:
  1817. {
  1818.             switch(yyvsp[0].i) {
  1819.             case -1: tmplreg[nlreg]->rtype = LR_TELE; break;
  1820.             case 0: tmplreg[nlreg]->rtype = LR_DOWNTELE; break;
  1821.             case 1: tmplreg[nlreg]->rtype = LR_UPTELE; break;
  1822.             }
  1823.             tmplreg[nlreg]->rname = 0;
  1824.             nlreg++;
  1825.           }
  1826. break;
  1827. case 154:
  1828. {
  1829.             tmplreg[nlreg] = New(lev_region);
  1830.             tmplreg[nlreg]->in_islev = yyvsp[0].i;
  1831.             tmplreg[nlreg]->inarea.x1 = current_region.x1;
  1832.             tmplreg[nlreg]->inarea.y1 = current_region.y1;
  1833.             tmplreg[nlreg]->inarea.x2 = current_region.x2;
  1834.             tmplreg[nlreg]->inarea.y2 = current_region.y2;
  1835.           }
  1836. break;
  1837. case 155:
  1838. {
  1839.             tmplreg[nlreg]->del_islev = yyvsp[0].i;
  1840.             tmplreg[nlreg]->delarea.x1 = current_region.x1;
  1841.             tmplreg[nlreg]->delarea.y1 = current_region.y1;
  1842.             tmplreg[nlreg]->delarea.x2 = current_region.x2;
  1843.             tmplreg[nlreg]->delarea.y2 = current_region.y2;
  1844.             tmplreg[nlreg]->rtype = LR_BRANCH;
  1845.             tmplreg[nlreg]->rname = 0;
  1846.             nlreg++;
  1847.           }
  1848. break;
  1849. case 156:
  1850. {
  1851.             yyval.i = -1;
  1852.           }
  1853. break;
  1854. case 157:
  1855. {
  1856.             yyval.i = yyvsp[0].i;
  1857.           }
  1858. break;
  1859. case 158:
  1860. {
  1861.             yyval.i = 0;
  1862.           }
  1863. break;
  1864. case 159:
  1865. {
  1866. /* This series of if statements is a hack for MSC 5.1.  It seems that its
  1867.    tiny little brain cannot compile if these are all one big if statement. */
  1868.             if (yyvsp[-7].i <= 0 || yyvsp[-7].i >= COLNO)
  1869.                 yyerror("Region out of level range!");
  1870.             else if (yyvsp[-5].i < 0 || yyvsp[-5].i >= ROWNO)
  1871.                 yyerror("Region out of level range!");
  1872.             else if (yyvsp[-3].i <= 0 || yyvsp[-3].i >= COLNO)
  1873.                 yyerror("Region out of level range!");
  1874.             else if (yyvsp[-1].i < 0 || yyvsp[-1].i >= ROWNO)
  1875.                 yyerror("Region out of level range!");
  1876.             current_region.x1 = yyvsp[-7].i;
  1877.             current_region.y1 = yyvsp[-5].i;
  1878.             current_region.x2 = yyvsp[-3].i;
  1879.             current_region.y2 = yyvsp[-1].i;
  1880.             yyval.i = 1;
  1881.           }
  1882. break;
  1883. case 160:
  1884. {
  1885.             tmpfountain[nfountain] = New(fountain);
  1886.             tmpfountain[nfountain]->x = current_coord.x;
  1887.             tmpfountain[nfountain]->y = current_coord.y;
  1888.             if (!in_room)
  1889.                 check_coord(current_coord.x, current_coord.y,
  1890.                     "Fountain");
  1891.             nfountain++;
  1892.           }
  1893. break;
  1894. case 161:
  1895. {
  1896.             tmpsink[nsink] = New(sink);
  1897.             tmpsink[nsink]->x = current_coord.x;
  1898.             tmpsink[nsink]->y = current_coord.y;
  1899.             nsink++;
  1900.           }
  1901. break;
  1902. case 162:
  1903. {
  1904.             tmppool[npool] = New(pool);
  1905.             tmppool[npool]->x = current_coord.x;
  1906.             tmppool[npool]->y = current_coord.y;
  1907.             npool++;
  1908.           }
  1909. break;
  1910. case 163:
  1911. {
  1912.             tmpdig[ndig] = New(digpos);
  1913.             tmpdig[ndig]->x1 = current_region.x1;
  1914.             tmpdig[ndig]->y1 = current_region.y1;
  1915.             tmpdig[ndig]->x2 = current_region.x2;
  1916.             tmpdig[ndig]->y2 = current_region.y2;
  1917.             ndig++;
  1918.           }
  1919. break;
  1920. case 164:
  1921. {
  1922.             tmppass[npass] = New(digpos);
  1923.             tmppass[npass]->x1 = current_region.x1;
  1924.             tmppass[npass]->y1 = current_region.y1;
  1925.             tmppass[npass]->x2 = current_region.x2;
  1926.             tmppass[npass]->y2 = current_region.y2;
  1927.             npass++;
  1928.           }
  1929. break;
  1930. case 165:
  1931. {
  1932.             tmpreg[nreg] = New(region);
  1933.             tmpreg[nreg]->x1 = current_region.x1;
  1934.             tmpreg[nreg]->y1 = current_region.y1;
  1935.             tmpreg[nreg]->x2 = current_region.x2;
  1936.             tmpreg[nreg]->y2 = current_region.y2;
  1937.             tmpreg[nreg]->rlit = yyvsp[-3].i;
  1938.             tmpreg[nreg]->rtype = yyvsp[-1].i;
  1939.             if(yyvsp[0].i & 1) tmpreg[nreg]->rtype += MAXRTYPE+1;
  1940.             tmpreg[nreg]->rirreg = ((yyvsp[0].i & 2) != 0);
  1941.             if(current_region.x1 > current_region.x2 ||
  1942.                current_region.y1 > current_region.y2)
  1943.                yyerror("Region start > end!");
  1944.             if(tmpreg[nreg]->rtype == VAULT &&
  1945.                (tmpreg[nreg]->rirreg ||
  1946.                 (tmpreg[nreg]->x2 - tmpreg[nreg]->x1 != 1) ||
  1947.                 (tmpreg[nreg]->y2 - tmpreg[nreg]->y1 != 1)))
  1948.                 yyerror("Vaults must be exactly 2x2!");
  1949.             if(want_warnings && !tmpreg[nreg]->rirreg &&
  1950.                current_region.x1 > 0 && current_region.y1 > 0 &&
  1951.                current_region.x2 < max_x_map &&
  1952.                current_region.y2 < max_y_map) {
  1953.                 /* check for walls in the room */
  1954.                 char ebuf[60];
  1955.                 register int x, y, nrock = 0;
  1956.  
  1957.                 for(y=current_region.y1; y<=current_region.y2; y++)
  1958.                 for(x=current_region.x1;
  1959.                     x<=current_region.x2; x++)
  1960.                     if(IS_ROCK(tmpmap[y][x]) ||
  1961.                        IS_DOOR(tmpmap[y][x])) nrock++;
  1962.                 if(nrock) {
  1963.                 Sprintf(ebuf,
  1964.                     "Rock in room (%02d,%02d,%02d,%02d)?!",
  1965.                     current_region.x1, current_region.y1,
  1966.                     current_region.x2, current_region.y2);
  1967.                 yywarning(ebuf);
  1968.                 }
  1969.                 if (
  1970.         !IS_ROCK(tmpmap[current_region.y1-1][current_region.x1-1]) ||
  1971.         !IS_ROCK(tmpmap[current_region.y2+1][current_region.x1-1]) ||
  1972.         !IS_ROCK(tmpmap[current_region.y1-1][current_region.x2+1]) ||
  1973.         !IS_ROCK(tmpmap[current_region.y2+1][current_region.x2+1])) {
  1974.                 Sprintf(ebuf,
  1975.                 "NonRock edge in room (%02d,%02d,%02d,%02d)?!",
  1976.                     current_region.x1, current_region.y1,
  1977.                     current_region.x2, current_region.y2);
  1978.                 yywarning(ebuf);
  1979.                 }
  1980.             } else if(tmpreg[nreg]->rirreg &&
  1981.         !IS_ROOM(tmpmap[current_region.y1][current_region.x1])) {
  1982.                 char ebuf[60];
  1983.                 Sprintf(ebuf,
  1984.                     "Rock in irregular room (%02d,%02d)?!",
  1985.                     current_region.x1, current_region.y1);
  1986.                 yyerror(ebuf);
  1987.             }
  1988.             nreg++;
  1989.           }
  1990. break;
  1991. case 166:
  1992. {
  1993.             tmpaltar[naltar] = New(altar);
  1994.             tmpaltar[naltar]->x = current_coord.x;
  1995.             tmpaltar[naltar]->y = current_coord.y;
  1996.             tmpaltar[naltar]->align = yyvsp[-2].i;
  1997.             tmpaltar[naltar]->shrine = yyvsp[0].i;
  1998.             if (!in_room)
  1999.                 check_coord(current_coord.x, current_coord.y,
  2000.                     "Altar");
  2001.             naltar++;
  2002.           }
  2003. break;
  2004. case 167:
  2005. {
  2006.             tmpgold[ngold] = New(gold);
  2007.             tmpgold[ngold]->x = current_coord.x;
  2008.             tmpgold[ngold]->y = current_coord.y;
  2009.             tmpgold[ngold]->amount = yyvsp[-2].i;
  2010.             if (!in_room)
  2011.                 check_coord(current_coord.x, current_coord.y,
  2012.                     "Gold");
  2013.             ngold++;
  2014.           }
  2015. break;
  2016. case 168:
  2017. {
  2018.             tmpengraving[nengraving] = New(engraving);
  2019.             tmpengraving[nengraving]->x = current_coord.x;
  2020.             tmpengraving[nengraving]->y = current_coord.y;
  2021.             tmpengraving[nengraving]->e.text = yyvsp[0].map;
  2022.             tmpengraving[nengraving]->etype = yyvsp[-2].i;
  2023.             if (!in_room)
  2024.                 check_coord(current_coord.x, current_coord.y,
  2025.                     "Engraving");
  2026.             nengraving++;
  2027.           }
  2028. break;
  2029. case 170:
  2030. {
  2031.             yyval.i = - MAX_REGISTERS - 1;
  2032.           }
  2033. break;
  2034. case 173:
  2035. {
  2036.             yyval.i = - MAX_REGISTERS - 1;
  2037.           }
  2038. break;
  2039. case 176:
  2040. {
  2041.             yyval.map = (char *) 0;
  2042.           }
  2043. break;
  2044. case 178:
  2045. {
  2046.             yyval.map = (char *) 0;
  2047.           }
  2048. break;
  2049. case 179:
  2050. {
  2051.             int token = get_trap_type(yyvsp[0].map);
  2052.             if (token == ERR)
  2053.                 yyerror("Unknown trap type!");
  2054.             yyval.i = token;
  2055.           }
  2056. break;
  2057. case 181:
  2058. {
  2059.             int token = get_room_type(yyvsp[0].map);
  2060.             if (token == ERR) {
  2061.                 yywarning("Unknown room type!  Making ordinary room...");
  2062.                 yyval.i = OROOM;
  2063.             } else
  2064.                 yyval.i = token;
  2065.           }
  2066. break;
  2067. case 183:
  2068. {
  2069.             yyval.i = 0;
  2070.           }
  2071. break;
  2072. case 184:
  2073. {
  2074.             yyval.i = yyvsp[0].i;
  2075.           }
  2076. break;
  2077. case 185:
  2078. {
  2079.             yyval.i = yyvsp[-2].i + (yyvsp[0].i << 1);
  2080.           }
  2081. break;
  2082. case 188:
  2083. {
  2084.             current_coord.x = current_coord.y = -MAX_REGISTERS-1;
  2085.           }
  2086. break;
  2087. case 195:
  2088. {
  2089.             yyval.i = - MAX_REGISTERS - 1;
  2090.           }
  2091. break;
  2092. case 198:
  2093. {
  2094.             if ( yyvsp[-1].i >= MAX_REGISTERS )
  2095.                 yyerror("Register Index overflow!");
  2096.             else
  2097.                 current_coord.x = current_coord.y = - yyvsp[-1].i - 1;
  2098.           }
  2099. break;
  2100. case 199:
  2101. {
  2102.             if ( yyvsp[-1].i >= MAX_REGISTERS )
  2103.                 yyerror("Register Index overflow!");
  2104.             else
  2105.                 yyval.i = - yyvsp[-1].i - 1;
  2106.           }
  2107. break;
  2108. case 200:
  2109. {
  2110.             if ( yyvsp[-1].i >= MAX_REGISTERS )
  2111.                 yyerror("Register Index overflow!");
  2112.             else
  2113.                 yyval.i = - yyvsp[-1].i - 1;
  2114.           }
  2115. break;
  2116. case 201:
  2117. {
  2118.             if ( yyvsp[-1].i >= 3 )
  2119.                 yyerror("Register Index overflow!");
  2120.             else
  2121.                 yyval.i = - yyvsp[-1].i - 1;
  2122.           }
  2123. break;
  2124. case 203:
  2125. {
  2126.             if (check_monster_char((char) yyvsp[0].i))
  2127.                 yyval.i = yyvsp[0].i ;
  2128.             else {
  2129.                 yyerror("Unknown monster class!");
  2130.                 yyval.i = ERR;
  2131.             }
  2132.           }
  2133. break;
  2134. case 204:
  2135. {
  2136.             char c = yyvsp[0].i;
  2137.             if (check_object_char(c))
  2138.                 yyval.i = c;
  2139.             else {
  2140.                 yyerror("Unknown char class!");
  2141.                 yyval.i = ERR;
  2142.             }
  2143.           }
  2144. break;
  2145. case 207:
  2146. {
  2147.             yyval.map = (char *) 0;
  2148.           }
  2149. break;
  2150. case 212:
  2151. {
  2152.             if (!in_room && !init_lev.init_present &&
  2153.                 (yyvsp[-3].i < 0 || yyvsp[-3].i > max_x_map ||
  2154.                  yyvsp[-1].i < 0 || yyvsp[-1].i > max_y_map))
  2155.                 yyerror("Coordinates out of map range!");
  2156.             current_coord.x = yyvsp[-3].i;
  2157.             current_coord.y = yyvsp[-1].i;
  2158.           }
  2159. break;
  2160. case 213:
  2161. {
  2162. /* This series of if statements is a hack for MSC 5.1.  It seems that its
  2163.    tiny little brain cannot compile if these are all one big if statement. */
  2164.             if (yyvsp[-7].i < 0 || yyvsp[-7].i > max_x_map)
  2165.                 yyerror("Region out of map range!");
  2166.             else if (yyvsp[-5].i < 0 || yyvsp[-5].i > max_y_map)
  2167.                 yyerror("Region out of map range!");
  2168.             else if (yyvsp[-3].i < 0 || yyvsp[-3].i > max_x_map)
  2169.                 yyerror("Region out of map range!");
  2170.             else if (yyvsp[-1].i < 0 || yyvsp[-1].i > max_y_map)
  2171.                 yyerror("Region out of map range!");
  2172.             current_region.x1 = yyvsp[-7].i;
  2173.             current_region.y1 = yyvsp[-5].i;
  2174.             current_region.x2 = yyvsp[-3].i;
  2175.             current_region.y2 = yyvsp[-1].i;
  2176.           }
  2177. break;
  2178.     }
  2179.     yyssp -= yym;
  2180.     yystate = *yyssp;
  2181.     yyvsp -= yym;
  2182.     yym = yylhs[yyn];
  2183.     if (yystate == 0 && yym == 0)
  2184.     {
  2185. #if YYDEBUG
  2186.         if (yydebug)
  2187.             printf("%sdebug: after reduction, shifting from state 0 to\
  2188.  state %d\n", YYPREFIX, YYFINAL);
  2189. #endif
  2190.         yystate = YYFINAL;
  2191.         *++yyssp = YYFINAL;
  2192.         *++yyvsp = yyval;
  2193.         if (yychar < 0)
  2194.         {
  2195.             if ((yychar = yylex()) < 0) yychar = 0;
  2196. #if YYDEBUG
  2197.             if (yydebug)
  2198.             {
  2199.                 yys = 0;
  2200.                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
  2201.                 if (!yys) yys = "illegal-symbol";
  2202.                 printf("%sdebug: state %d, reading %d (%s)\n",
  2203.                         YYPREFIX, YYFINAL, yychar, yys);
  2204.             }
  2205. #endif
  2206.         }
  2207.         if (yychar == 0) goto yyaccept;
  2208.         goto yyloop;
  2209.     }
  2210.     if ((yyn = yygindex[yym]) != 0 && (yyn += yystate) >= 0 &&
  2211.             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
  2212.         yystate = yytable[yyn];
  2213.     else
  2214.         yystate = yydgoto[yym];
  2215. #if YYDEBUG
  2216.     if (yydebug)
  2217.         printf("%sdebug: after reduction, shifting from state %d \
  2218. to state %d\n", YYPREFIX, *yyssp, yystate);
  2219. #endif
  2220.     if (yyssp >= yyss + yystacksize - 1)
  2221.     {
  2222.         goto yyoverflow;
  2223.     }
  2224.     *++yyssp = yystate;
  2225.     *++yyvsp = yyval;
  2226.     goto yyloop;
  2227. yyoverflow:
  2228.     yyerror("yacc stack overflow");
  2229. yyabort:
  2230.     return (1);
  2231. yyaccept:
  2232.     return (0);
  2233. }
  2234.